script:
wait(1) local event1 = game.ReplicatedStorage.Events:FindFirstChild("GuiEvent") local db = false script.Parent.Touched:Connect(function(hit) if db == false then local character = hit.Parent local player = game.Players:GetPlayerFromCharacter(character) db = true event1:FireClient(player) print("event fired") wait(3) db = false end end)
local eventA = game.ReplicatedStorage.Events:FindFirstChild("GuiEvent") local db = false script.Parent.Touched:Connect(function(hit) if db == false then if game.Players:GetPlayerFromCharacter(hit.Parent) then local player = game.Players:GetPlayerFromCharacter(hit.Parent) db = true eventA:FireClient(player) print("event fired") wait(3) db = false end end end)
local event1 = game.ReplicatedStorage.Events:FindFirstChild("GuiEvent") local db = false script.Parent.Touched:Connect(function(hit) if db == false then local character = hit.Parent local player = game.Players:GetPlayerFromCharacter(character) db = true event1:FireClient(player) print("event fired") wait(3) db = false end end)
If this doesn't work then check if touched part has humanoid.
What I'm assuming here is that if the part is touching something other then a player then it's trying to get the player from that, and because it's not a player, it's giving you this error.
If you want this to only work if a player touches the part you can do this:
wait(1) local event1 = game.ReplicatedStorage.Events:FindFirstChild("GuiEvent") local db = false script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if db == false then local character = hit.Parent local player = game.Players:GetPlayerFromCharacter(character) db = true event1:FireClient(player) print("event fired") wait(3) db = false end end end)