Why does my touched event work only if a certain person does it?
Asked by
3 years ago Edited 3 years ago
I'm making something where you claim an area if you walk up to it, and then nobody can walk into yours and you can't walk into anyone else's
In Studio it works perfectly, but when I go into the game with my alt, things get confusing
The touched events seem to only trigger when I do it, when my alt does it, literally nothing happens, and on top of that, it happens for everyone, not just me
What?
Code (ServerScript in ServerScriptService):
01 | local Nil = game.Players:WaitForChild( "Nil" ) |
02 | local Owner 1 = Instance.new( "StringValue" ) |
03 | local Owner 2 = Instance.new( "StringValue" ) |
05 | game.Players.PlayerAdded:Connect( function (player) |
07 | player.Nil.Value = true |
10 | game.Workspace.Slot 1. Ownership.Touched:Connect( function (hit) |
11 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
12 | local Player = game.Players:GetPlayerFromCharacter(hit.Parent) |
13 | if Owner 1. Value = = "" and Player.Nil.Value = = true then |
14 | Owner 1. Value = Player.Name |
15 | Player.Nil.Value = false |
16 | game.Workspace.Slot 1. GUI.BillboardGui.TextLabel.Visible = false |
20 | if Player.Name = = Owner 1. Value then |
21 | game.Workspace.Slot 1. Ownership.CanCollide = false |
26 | game.Workspace.Slot 2. Ownership.Touched:Connect( function (hit) |
27 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
28 | local Player = game.Players:GetPlayerFromCharacter(hit.Parent) |
29 | if Owner 2. Value = = "" and Player.Nil.Value = = true then |
30 | Owner 2. Value = Player.Name |
31 | Player.Nil.Value = false |
32 | game.Workspace.Slot 2. GUI.BillboardGui.TextLabel.Visible = false |
36 | if Player.Name = = Owner 2. Value then |
37 | game.Workspace.Slot 2. Ownership.CanCollide = false |