Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
6 years ago

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.

0
Forgot to check this again but thank you very much! Phantom1996 45 — 6y
Ad

Answer this question