For some reason, there variables in my function are preventing the script from working. (I figured this out with process of elimination). Any idea why?
local event = game:GetService("ReplicatedStorage"):WaitForChild("Folder"):WaitForChild("event")
--this one isn't the problem
event.OnServerEvent:Connect(function(plr)
local stats = plr:WaitForChild("leaderstats")
local points = stats:WaitForChild("points")
print("Success") --this doesn't print
end)
local player = game.Players.LocalPlayer
local event = game:GetService("ReplicatedStorage"):WaitForChild("Folder"):WaitForChild("event")
local canhit = true
script.Parent.MouseButton1Click:Connect(function()
if canhit == true then
canhit = false
event:FireServer()
task.wait(1)
canhit = true
end
end)
It’s a localscript inside of a button in a gui. The server script is inside there as well to change leaderstats
sorry i accidently clicked enter on my last post, but here i have the full one.
I think that because you are using WaitForChild() on an instance that might not be found at any time (usually not the case, but it works preventative), it detects an infinite yield possibility and doesn’t run the rest either.
I got that error, but I haven’t been able to find any solutions that apply to my situation, and most people say it’s not an error just a warning. Any ideas how to fix?
does the leaderstats folder actually exist… because that would be the only possible issue with this. (and would explain the infinite yielding warning)
Must have been a formatting issue then, because the infinite yield warning is gone. Doesn’t need to be moved to serverscriptservice though for my case