(Bear with me here, this might be a little confusing) Alright so I'm super new to scripting and trying to figure out how to make this one line of code. What happens is, this server script,
game.Players.PlayerAdded:connect(function(player)
local event = Instance.new("Folder")
event.Name = "Events"
event.Parent = player
end)
creates a folder in the local player. Then this server script creates an event within the folder and fires the event when the parent brick is clicked on, which sends a client fire thingy(forgot what they're called) to a local script in StarterPlayerScripts.
game.Players.PlayerAdded:connect(function(player)
local click = Instance.new("ClickDetector")
click.Parent = workspace.cap
local event = Instance.new("RemoteEvent")
event.Parent = game.Players.LocalPlayer:WaitForChild("Events")
event.Name = "cow"
click.MouseClick:connect(function(player)
event:FireClient(player)
end)
end)
This is the local script.
local h = game.Players.LocalPlayer:WaitForChild("Events"):WaitForChild("cow").OnClientEvent:connect(function()
local v = game.Players.LocalPlayer:WaitForChild("PlayerData"):WaitForChild("cowss")
v.Value = v.Value + 10
local t = game.Players.LocalPlayer.PlayerGui:WaitForChild("cows").Frame.s
t.Text = v.Value
end)
"cows" is the name of the gui in StarterGui. This whole script thing is supposed to, when you click on a part, add a value to the player's data, then update the gui so that is shows how much you have clicked on it.
When I open it up in the studio, everything works great, but when I open it up in game, nothing works and I get the message 'Infinite yield on Players.Devetious7.Events:WaitForChild("cow")'. If this is a bit too confusing the way I'm explaining it then I could give anyone who is willing to help team building permissions so they could fix it. Any help is appreciated, thanks.
