Hello there, I have been working on this script for my upcoming game and I am encountering a problem
local button = script.Parent
local Platform1 = button.Parent.Parent.Parent.Teleportpad
local Platform2 = button.Parent.Parent.Parent.Outsidepad
local Replicated_Storage = game.ReplicatedStorage
local Proximit_Prompt = button.ProximityPrompt
local Position = "Out"
local PlayerLocalScript = Replicated_Storage.Prompt_Text_Change
Proximit_Prompt.Triggered:Connect(function(player)
local PlayerName = player.Name
local Character = game.Workspace:FindFirstChild(PlayerName)
local Humanoid_Root_Part = Character.HumanoidRootPart
PlayerLocalScript.Parent = Character
PlayerLocalScript.Enabled = true
local TextChangeEvent = Instance.new("RemoteEvent", Replicated_Storage)
TextChangeEvent.Name = "Text Change Event"
if Position == "Out" then
print("Event-1 Fired")
print(PlayerName .. " has joined the queue for Classic match.")
local NewPos = Platform1.Position + Vector3.new(0,8,0)
Position = "In"
local PromptMessage = "Leave Queue"
TextChangeEvent:FireClient(player, Position, PromptMessage, Proximit_Prompt)
Humanoid_Root_Part.Position = NewPos
return Position
end
if Position == "In" then
print("Event-2 Fired")
print(PlayerName .. " has left the queue for Classic match.")
local NewPos = Platform2.Position + Vector3.new(0,8,0)
Position = "Out"
TextChangeEvent:FireClient(player, Position, Proximit_Prompt)
Humanoid_Root_Part.Position = NewPos
return Position
end
end)
This is my server script and
local Replicated_Storage = game.ReplicatedStorage
local TextChangeEvent = Replicated_Storage:WaitForChild("Text Change Event")
TextChangeEvent.OnClientEvent:Connect(function(Position, PromptMessage, Proximit_Prompt)
print("Event Detected")
print(PromptMessage)
end)
This is my local script
When ever I test it, the first time, when I trigger the proximity prompt, everything works just fine, but when I trigger it the second time, the local script does not detect the event fired. I tried setting initial “Position” to “In” and tried but again only the first time it detects the event firing and then it stops detecting
I keep a check using this output here
Could someone please tell me what I am doing wrong that is causing this problem or what should I do to make it detect it whenever and whatever time it happens