O'k so iv'e spent forever looking at Filtering Enabled and why scripts won't work in a Roblox client but i can not get this to work...iv'e even tried using Events. So this works fine in Studio but not Player...What am i doing wrong? It is suppose to Clone a Accessory from ServerStorage and put it into the Character, and i have tried the EquipAccessory function in humanoid already.
The script below is a Local script
script.Parent.Hair1.Changed:connect(function() local Player = game.Players.LocalPlayer local CHR = Player.Character local HValue = script.Parent.Hair1.Value script.Convert:Fire(HValue,CHR) end)
The script below is a Server script inside the Local script
script.Parent.Convert.Event:connect(function(HValue,CHR) local GCH = game.ServerStorage.Player_Body_Parts.Head.Hair local CH = GCH:FindFirstChild(HValue) local CHH = CH:Clone() for i,v in pairs(script.Parent.Parent.Parent:GetChildren())do if v.Name ~= "Hair1" or v.Name ~= "Hair2" then if v.Name == "Hair1" or v.Name == "Hair2" then v:Destroy() end end end CHH.Name = "Hair1" CHH.Parent = CHR end)
The scripts and Hair1 value are inside a Folder of the Players Character. Why wont it work?
Since you use the syntax :Fire
and .Event
I assume you are trying to manipulate a BindableEvent from the client. This is not allowed. Use a remote event.
Besides the inefficiencies that this script looks to have, this is how it might look with a RemoteEvent. It is simple syntax differences.
script.Parent.Hair1.Changed:connect(function() local Player = game.Players.LocalPlayer local CHR = Player.Character local HValue = script.Parent.Hair1.Value script.Convert:FireServer(HValue,CHR) end)
script.Parent.Convert.OnServerEvent:connect(function(player,HValue,CHR) local GCH = game.ServerStorage.Player_Body_Parts.Head.Hair local CH = GCH:FindFirstChild(HValue) local CHH = CH:Clone() for i,v in pairs(script.Parent.Parent.Parent:GetChildren())do if v.Name ~= "Hair1" or v.Name ~= "Hair2" then if v.Name == "Hair1" or v.Name == "Hair2" then v:Destroy() end end end CHH.Name = "Hair1" CHH.Parent = CHR end)