I am creating a system where when you press one button, its value changes to true via a bool and the transparency of the arrow is changed to 1. But by pressing on side of the button, it changes the other side and bugs really weirdly. Here is a video showing.
Main Script
for _, queuepad in pairs (TeamPads) do
if queuepad:IsA("BasePart") then
queuepad.ClickDetector.MouseClick:Connect(function(player)
if queuepad.Occupied.Value == false and CheckIfCurrentPlayer(player) == false and script.Parent.Players:FindFirstChild(queuepad.Name).Value == nil and GameStatus.GameReady.Value == true then
queuepad.Occupied.Value = true
local Pad = script.Parent.QueuePlayers:FindFirstChild(queuepad.Name)
Pad.Value = player
local character = player.Character
character.HumanoidRootPart.CFrame = CFrame.new(queuepad.Position + Vector3.new(0,2,0)) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))
character.Humanoid.WalkSpeed = 0
wait(1)
character.HumanoidRootPart.Anchored = true
local function getData(player)
if queuepad.Occupied.Value == true then
local arrowPart = game.Workspace["[FIRST]1v1"].Queue.Player1.arrowPart.Decal
arrowPart.Transparency = 1
else
local arrowPart = game.Workspace["[FIRST]1v1"].Queue.Player1.arrowPart.Decal
arrowPart.Transparency = 0
end
end
RE.OnServerEvent:Connect(getData)
--Hop Off Gui
local HopOff = script.HopOff:Clone()
HopOff.Parent = player.PlayerGui
HopOff.Frame.ImageLabel.TextButton.Script.Disabled = false
HopOff.TeamPad.Value = queuepad
--local function pressedInputed()
-- local arrowPart = game.Workspace["[FIRST]1v1"].Queue.Player1.arrowPart.Decal
-- if queuepad.Occupied.Value == false then
-- remove.Transparency = 0
-- arrowPart.Transparency = 0
-- else
-- return nil
-- end
--end
--R2.OnServerEvent:Connect(pressedInputed)
elseif GameStatus.GameReady.Value == false and CheckIfCurrentPlayer(player) == false and queuepad.Occupied.Value == false then
if queuepad.Name == "Player2" then
queuepad.Occupied.Value = true
local arrowTwo = game.Workspace["[FIRST]1v1"].Queue.Player2.PartForArrow.Decal
local Pad = script.Parent.QueuePlayers:FindFirstChild(queuepad.Name)
Pad.Value = player
local character = player.Character
character.HumanoidRootPart.CFrame = CFrame.new(queuepad.Position + Vector3.new(0,2,0)) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))
character.Humanoid.WalkSpeed = 0
wait(1)
character.HumanoidRootPart.Anchored = true
game.ReplicatedStorage:WaitForChild("SecTrans").OnServerEvent:Connect(function()
if queuepad.Occupied.Value == true and queuepad.Name == 'Player2' and not queuepad.Name == 'Player2' then
local arrowTwo = game.Workspace["[FIRST]1v1"].Queue.Player2.PartForArrow.Decal
arrowTwo.Transparency = 1
else
local arrowTwo = game.Workspace["[FIRST]1v1"].Queue.Player2.PartForArrow.Decal
arrowTwo.Transparency = 0
end
end)
--Hop Off Gui
local HopOff = script.HopOff:Clone()
HopOff.Parent = player.PlayerGui
HopOff.Frame.ImageLabel.TextButton.Script.Disabled = false
HopOff.TeamPad.Value = queuepad
end
end
end)
end
end
script.Parent.Queue.Player2.Occupied:GetPropertyChangedSignal("Value"):Connect(function()
if script.Parent.Queue.Player2.Occupied.Value == false then
wait(1)
game.Workspace["[FIRST]1v1"].Queue.Player2.PartForArrow.Decal.Transparency = 0
end
end)
-- Prevents it from glitching out
GameStatus.GameReady.Value = true
Second Script –This is where when you press the button from the video, the events fires
script.Parent.MouseButton1Click:Connect(function()
local RemoteEvent = game:GetService('ReplicatedStorage'):WaitForChild('ChangeTrans')
local RE = game:GetService('ReplicatedStorage'):WaitForChild('DiffTrans')
local remove = game.Workspace["[FIRST]1v1"].Queue.Player1.Extra.Union:GetChildren()
local arrForPlayer2 = game.Workspace["[FIRST]1v1"].Queue.Player2.PartForArrow.Decal
local arrowPart = game.Workspace["[FIRST]1v1"].Queue.Player1.arrowPart.Decal
--Player 2
local TeamPart = script.Parent.Parent.Parent.Parent.TeamPad
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
player.Character.HumanoidRootPart.Anchored = false --Player can walk
player.Character.Humanoid.WalkSpeed = 16
arrowPart.Transparency = 1
arrForPlayer2.Transparency = 1
-----For Player 2
player.Character.HumanoidRootPart.CFrame = CFrame.new(TeamPart.Value.Position)
for _,v in pairs (TeamPart.Value.Parent.Parent.QueuePlayers:GetChildren()) do --Removes playervalue
if v.Value == player then
v.Value = nil
end
end
for _,v in pairs (TeamPart.Value.Parent.Parent.Players:GetChildren()) do --Removes playervalue
if v.Value == player then
v.Value = nil
end
end
TeamPart.Value.Occupied.Value = false --makes it unoccupied
--RE.OnServerEvent:Connect(getTrans)
script.Parent.Parent.Parent.Parent:Destroy()
end)
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
local Char = player.Character
Char.Humanoid.HealthChanged:Connect(function()
if Char.Humanoid.Health >=0 then
warn("Player reset while in queue")
local TeamPad = script.Parent.Parent.Parent.Parent.TeamPad.Value
TeamPad.Occupied.Value = false
for _,v in pairs (TeamPad.Parent.Parent.QueuePlayers:GetChildren()) do --Removes playervalue
if v.Value == player then
v.Value = nil
end
end
end
end)
Local Script
local RemoteEvent = game:GetService('ReplicatedStorage'):WaitForChild('ChangeTrans')
local diffEvent = game:GetService('ReplicatedStorage'):WaitForChild('DiffTrans')
local Trans = game:GetService('ReplicatedStorage'):WaitForChild('SecTrans')
while wait(1) do
Trans:FireServer()
wait(0.03)
RemoteEvent:FireServer()
wait(0.03)
diffEvent:FireServer()
wait(0.5)
end
All help is appericated