Could i have some help please with my script thanks

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

RegisterNetEvent("changeskin")
AddEventHandler("changeskin", function()
	cancelEvent()
	SetPlayerModel(player player,  s_m_y_cop_01)
end)

you arent even ending your if???

Why are you asking for help on literally every script you make, you aint gonna learn anything like t hat

I know that i said it just a start i dont end my if untill the code is completed for the if

Well nothing is gonna happen without finishing the if statement

Because i try the script and if it dont work i ask for help but im just seeing if i have done this one right i promis i wont ask again unless i have to

want to make sure i am doing it right

The only way to make sure you are doing something right is by testing what you have done. If you are having issues, I suggest you first strengthen up your skills on lua first and have a look at other resources before you dive into making your own.

1 Like

I am just asking if what is done so fare is correct

Test it? See if it works. You don’t need to clog up the forums every time you want to see if something works or not.

well, the fact that you Havent even defined player and hash hell no

I have tested it is the thing i tested it but not sure if its my five m or its not working thats all

Its all wrong now i think about it, running them natives from a server sided script?

youre also using SET_PLAYER_MODEL Which in lua would be SetPlayerModel

Oh ok well thats why it didnt work then

You need to send a client event from the server which will then trigger the skin change

Ok thanks ill try that then

No, it’s not. It’s riddled with syntax errors…
Honesty, the best thing to do is learn how to program in a language, then you can come back and figure out the particulars of FiveM.

You can start learning Lua or C#. Once you know how to program in the language, you can look at other peoples resources to figure out how to do stuff. You can also take a look at the wiki or, the natives to find what can and can’t be used.

2 Likes

I know the basics of lua just finding it hard to learn the scripting of it.

By looking at your code, I would say you need to take another look at learning Lua. You’ve made some very basic mistakes. This includes, missing parentheses, missing functions, missing variables, not calling functions correctly, not ending conditions and wrong variable assignments.

And also learn the gta 5 natives :wink:

1 Like