LocalScript:
local player = game.Players.LocalPlayer local UIS = game:GetService("UserInputService") local debounce1 = true local animation = game.ReplicatedStorage.anims.shoot UIS.InputBegan:Connect(function(key, gameproccessed) if key.UserInputType == Enum.UserInputType.MouseButton1 then if debounce1 then debounce1 = false game.ReplicatedStorage.ClickEvent:FireServer(animation) local length = game.ReplicatedStorage.ClickEventReturn:InvokeServer(animation) -- where it fires from wait(length + 0.1) debounce1 = true end end end)
Script:
function send(player, animation) print(player, animation) -- prints "nil nil" local track = Instance.new("Humanoid"):LoadAnimation(animation) -- errors print(track.Length) return track.Length end game.ReplicatedStorage.ClickEventReturn.OnServerInvoke = send()
This for some reason is printing nil, when i specified the argument in the localscript. And i assume the first argument would be the player. Whats wrong here?
Help pls
Thx
well the problem is you did game.ReplicatedStorage.ClickEventReturn.OnServerInvoke = send()
.. remember, when you do FunctionName()
that calls the function... so doing send()
without any arguments is is causing the print statement to print nil.. b/c again, the function was called with nil arguments.. so replace that line with:
game.ReplicatedStorage.ClickEventReturn.OnServerInvoke = send
without the parenthesis..