redditing Posted July 3, 2020 Share Posted July 3, 2020 what server-side getLocalPlayer looks like? Link to comment
nxFairlywell Posted July 3, 2020 Share Posted July 3, 2020 (edited) Local player is actually the client! So server side script hasn't local player because the script is server side you should use this in client side triggerServerEvent("EventName",localPlayer) -- localPlayer = source of the event in server side and you can receive your event from server side like this : addEvent("EventName",true) addEventHandler("EventName",root, function() local localPlayer = source; -- source is that player you put in the triggerServerEvent -- now you have the localPlayer in the server end ) also, there are another methods you can use, but this is a simple example. Note : When you need to use the localPlayer in server side, you will be automatically must be using the triggerServerEvent function. So in the logic you have to trigger an event When you want to use localPlayer? Edited July 3, 2020 by VenomNX Link to comment
Scripting Moderators ds1-e Posted July 3, 2020 Scripting Moderators Share Posted July 3, 2020 20 minutes ago, VenomNX said: Local player is actually the client! So server side script hasn't local player because the script is server side you should use this in client side triggerServerEvent("EventName",localPlayer) -- localPlayer = source of the event in server side and you can receive your event from server side like this : addEvent("EventName",true) addEventHandler("EventName",root, function() local localPlayer = source; -- source is that player you put in the triggerServerEvent -- now you have the localPlayer in the server end ) also, there are another methods you can use, but this is a simple example. Note : When you need to use the localPlayer in server side, you will be automatically must be using the triggerServerEvent function. So in the logic you have to trigger an event When you want to use localPlayer? Using source variable isn't safe. function EventName() if client then outputChatBox("Hi player!", client) end end addEvent("EventName", true) addEventHandler("EventName", root, EventName) Quote All parameters including 'source' can be faked and should not be trusted. Global variable 'client' can be trusted. https://wiki.multitheftauto.com/wiki/Script_security 1 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now