script:
01 | wait( 1 ) |
02 | local event 1 = game.ReplicatedStorage.Events:FindFirstChild( "GuiEvent" ) |
03 | local db = false |
04 |
05 | script.Parent.Touched:Connect( function (hit) |
06 | if db = = false then |
07 | local character = hit.Parent |
08 | local player = game.Players:GetPlayerFromCharacter(character) |
09 | db = true |
10 | event 1 :FireClient(player) |
11 | print ( "event fired" ) |
12 | wait( 3 ) |
13 | db = false |
14 | end |
15 | end ) |
01 | local eventA = game.ReplicatedStorage.Events:FindFirstChild( "GuiEvent" ) |
02 | local db = false |
03 |
04 | script.Parent.Touched:Connect( function (hit) |
05 | if db = = false then |
06 | if game.Players:GetPlayerFromCharacter(hit.Parent) then |
07 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
08 | db = true |
09 | eventA:FireClient(player) |
10 | print ( "event fired" ) |
11 | wait( 3 ) |
12 | db = false |
13 | end |
14 | end |
15 | end ) |
01 | local event 1 = game.ReplicatedStorage.Events:FindFirstChild( "GuiEvent" ) |
02 | local db = false |
03 |
04 | script.Parent.Touched:Connect( function (hit) |
05 | if db = = false then |
06 | local character = hit.Parent |
07 | local player = game.Players:GetPlayerFromCharacter(character) |
08 | db = true |
09 | event 1 :FireClient(player) |
10 | print ( "event fired" ) |
11 | wait( 3 ) |
12 | db = false |
13 | end |
14 | 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:
01 | wait( 1 ) |
02 | local event 1 = game.ReplicatedStorage.Events:FindFirstChild( "GuiEvent" ) |
03 | local db = false |
04 |
05 | script.Parent.Touched:Connect( function (hit) |
06 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
07 | if db = = false then |
08 | local character = hit.Parent |
09 | local player = game.Players:GetPlayerFromCharacter(character) |
10 | db = true |
11 | event 1 :FireClient(player) |
12 | print ( "event fired" ) |
13 | wait( 3 ) |
14 | db = false |
15 | end |
16 | end |
17 | end ) |