Need some help please with setting player model when /lspd is triggered

Hi I have started making a script which gives you the lspd skin but not sure how to activate it if someone could help me then great.

server.lua

AddEventHandler(‘chatMessage’, function(source, name, message)
command = string.lower( command )
if(command[1] == “/lspd”) then
CancelEvent()
TriggerClientEvent(‘changeskin’, source)
end
end)
CLIENT.LUA

local lspdmodel = SetPlayerModel (s_m_y_cop_01)

RegisterNetEvent(“changeskin”)
AddEventHandler(“changeskin”, function()
cancelEvent()
TriggerClientEvent(lspdmodel, source)
end)

you’re missing an end)

AddEventHandler('chatMessage', function(source, n, message)
    command = stringsplit(message, " ")
	if(command[1] == "/help") then
    CancelEvent()
    --put what you want here
    end
end)


function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

and also, commands are a server side script, not client

I know they aret client side i have changed that ages ago but thanks for the help again sorry to keep asking for help

Do you mean you know they arent client side?

Yeh sorry i ment i know they arent

what i sent a few messages ago should work

It still don’t work? for some reason i type /help but nothing happens there is a error in the console

Error parsing script server.lua in resource command: server.lua:5: unexpected symbol near ‘…’
Failed to load script server.lua.

send me what youve got now as in, your code

could you send it in code formatting, instead of an image

AddEventHandler(‘chatMessage’, function(source, n, message)
command = stringsplit(message, " ")
if(command[1] == “/help”) then
CancelEvent()
TriggerClientEvent(‘chatMessage’, source, …name, {255, 0, 0}, “hello”)
end
end)

function stringsplit(inputstr, sep)
if sep == nil then
sep = “%s”
end
local t={} ; i=1
for str in string.gmatch(inputstr, “([^”…sep…"]+)") do
t[i] = str
i = i + 1
end
return t
end

AddEventHandler('chatMessage', function(source, n, message)
    command = stringsplit(message, " ")
    if(command[1] == "/help") then
     CancelEvent()
      TriggerClientEvent('chatMessage', source, ..name, {255, 0, 0}, "hello")
    end
end)


function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end
AddEventHandler('chatMessage', function(source, n, message)
    command = stringsplit(message, " ")
	if(command[1] == "/help") then
    CancelEvent()
    TriggerClientEvent("chatMessage", source, n, {255, 0, 0}, "hello")
    end
end)


function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

there, tried and it works

What did i do wrong though so i can learn next time

Thanks it works now :slight_smile:

you had .. which was unnecessary and at the top you can see AddEventHandler('chatMessage', function(source, n, message) which you had name instead of just n in your chatmessage event

Ah ok thanks also i did ask you if you wanted to be a dev for a good community which is in developmen not ope to the public yet but i am head admin we have been working hard trying to make he community a good community and we would love it if you could dev for us as i could help dev but im not the best that way i can learn in the process of developing.

There is a sub category specifically for this: https://forum.cfx.re/c/server-development/server-bazaar

Want to promote your server, look for new players, find developers, or whatever? Go here! Make sure to adhere to the FiveM Service Agreement when posting in the Server Bazaar.

And learn how to use the edit function on your posts instead of creating two or more posts in a row.