Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my bindable function hanging up when invoked and not running?

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?

1 answer

✓ Accepted answer

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.

1 comment

0

Forgot to check this again but thank you very much!

This discussion is preserved as it was. New answers, comments, and votes are closed.