Yes, that is possible. Though, you can't send from ServerScript to LocalScript but you can do the opposite. Please remember, LocalScripts are for GUIs, while ServerScripts are for physical objects. Never do the opposite. Also, I bet you will know how to get around the problem by using StarterCharacterScripts since it seems like you are messing with the character.
Lastly, before I start you can't do game.Players.LocalPlayer inside a ServerScript. You will have to receive player in a certain way. game.Players.PlayerAdded:Connect(function(plr)
or remote events etc.
There are 2 ways to do this:
ModuleScript
or
RemoteEvents
In a LocalScript, you can send a variable to a server script.
Like so:
local color = 'Blue'
local RE = game:GetService('ReplicatedStorage'):WaitForChild('ColorEvent')
RE:FireServer(color)
now you can send more then 1 variable and you can do RE:FireServer inside functions
local color = 'Blue'
local RE = game:GetService('ReplicatedStorage'):WaitForChild('ColorEvent')
Button.MouseButton1Down:Connect(function()
RE:FireServer(color)
end)
from a ServerScript this is how you receive the data, note that player is automatically defined by RE:FireServer().
ServerScript:
local RE = game:GetService('ReplicatedStorage'):WaitForChild('ColorEvent')
RE.OnServerEvent:Connect(function(plr, blue)
end)
Or from a module script you can make a entire dictionary full of what each variable is and require it.
Here are some link if you still don't understand:
https://www.youtube.com/watch?v=qrulMMc0cNI
http://wiki.roblox.com/index.php?title=API:Class/ModuleScript&redirect=no
https://www.youtube.com/watch?v=4Dc_bri9mjs
http://wiki.roblox.com/index.php?title=API:Class/RemoteEvent
http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions
Now there may be more ways but these 2 are probably the most popular ways as they are simple. If this helped you in anyway, please Upvote and accept answer
-- Your Orange, BlackOrange3343
PS: Good luck
1 comment
1:You can't get the HumanoidRootPart from the LocalPlayer in Players folder. 2:You need a local script to access Local Player, server script will not access localPlayer