I have this local script in my Player's Gui
print("Starting") game.ReplicatedStorage:WaitForChild("GetStat"):InvokeServer("swordSkill") print("Finished")
And this inside a bindable function within the ReplicatedStorage
function script.Parent.OnServerInvoke(player,statName) print("Invoked") return game.ServerStorage:FindFirstChild(player.Name):FindFirstChild(statName).Value end
The Local Script starts, but when it reaches the invoking line, it hangs up and stops. There's no error, and the script inside the bindable function doesn't run. I've tried other methods for my script including:
script.Parent.OnServerInvoke:Connect(function(player,statName) print("Invoked") return game.ServerStorage:FindFirstChild(player.Name):FindFirstChild(statName).Value end)
and
script.Parent.OnServerInvoke = function(player,statName) print("Invoked") return game.ServerStorage:FindFirstChild(player.Name):FindFirstChild(statName).Value end
All produce the same results. Why isn't the bindable function being invoked?
Scripts don't run inside ReplicatedStorage, so that script refering to the event as script.Parent
isn't going to run.
You'll instead need to define OnServerInvoke
in a Script sitting in ServerScriptService.