So I don’t know what happened with my code but when I try firing an event, it just gives me an error saying Argument 1 missing or nil. What’s wrong with it? It worked fine in other scripts…
Script:
s.Touched:Connect(function(touch)
local h = touch.Parent:FindFirstChild("Humanoid")
if h then
local player = game.Players:GetPlayerFromCharacter(touch.Parent)
if player then
-- unrelated code here
end
event:FireClient()
end
end)
s.Touched:Connect(function(touch)
local h = touch.Parent:FindFirstChild("Humanoid")
if h then
local player = game.Players:GetPlayerFromCharacter(touch.Parent)
if player then
-- unrelated code here
end
event:FireClient(player)
end
end)
the issue is that you need to specify what client you want to fire to
Like @schaap5347 has mentioned, the remoteEvent:FireClient() method requires you to pass a player value, like remoteEvent:FireClient(player). This is why your script is erroring. That’s all you need to fix the script.
s.Touched:Connect(function(touch)
if touch.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(touch.Parent)
if player then
-- unrelated code here
end
event:FireClient()
end
end)
s.Touched:Connect(function(touch)
local h = touch.Parent:FindFirstChild("Humanoid")
if h then
local player = game.Players:GetPlayerFromCharacter(touch.Parent)
if player then
-- unrelated code here
end
event:FireClient(player)
end
end)