I have a script, parented to a part. Here's the code:
local trapPart = script.Parent
local function onPartTouch(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
-- Set player's health to 0
humanoid.WalkSpeed = 1
humanoid.JumpPower = 0
repeat
humanoid.Health = humanoid.Health - 1
wait(1)
until humanoid.Health == 0
print("Player has Died!")
game.ReplicatedStorage.RemoteEvent:FireClient()
wait(5)
end
end
trapPart.Touched:Connect(onPartTouch)
And the FireClient, is locating to a LocalScript parented to a TextButton, here's the script:
local button = script.Parent
button.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
player.Character.Humanoid.Health = 0
game.ReplicatedStorage.RemoteEvent:FireServer()
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function() -- Detecting the FireClient
game.ReplicatedStorage.RemoteEvent:FireServer()
end)
button.Visible = false
repeat wait() until player.Character.Humanoid.Health == 100
button.Visible = true
end)
But for some reason, this is what comes in the output.
21:49:57.208 - Argument 1 missing or nil
Any help with this?

1 comment
Don't forget that the first argument in a remote event is always going to be the player