i am trying to find the player in the workspace but it only works in local scripts. can you help me try to locate it regular scripts.
Failing code in regular script
local player = game.Players.LocalPlayer.Name --Find Player name local nameofplayer = game.Workspace:FindFirstChild(player) --Get the player in workspace script.Parent.MouseButton1Click:Connect(function() nameofplayer.Head.BrickColor = BrickColor3.Blue()
You should probably handle GUIs with Localscripts. You can however change the color of the head on the server using Remote Events
You can find more about remote Events and functions here: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
Insert a remote event in ReplicatedStorage
and insert a regular script into ServerScriptService
heres the Localscript: (put it in the button)
local player = game.Players.LocalPlayer local character = player.Character -- finds the player in the workspace local event = game.ReplicatedStorage. -- type the name of the remote event here script.Parent.MouseButton1Click:Connect(function() event:FireServer()
put this in the regular script in ServerScriptService:
local event = game.ReplicatedStorage. -- type the name of the remote event here event.OnServerEvent:Connect(function(player) player.Character.Head.BrickColor = -- color here
Sorry if this is incorrect. I'm kinda new to scripting too
Your going to have to use RemoteEvents in order to do this. This is due to ROBLOX Filtering Enabled restrictions.