Replacing buttons when a player dies

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to replace a button when a player dies, so that when he/she plays again, he/she can step on the button again.
  2. What is the issue? Include screenshots / videos if possible!
    I can’t seem to replace the buttons when the player dies.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried remote events, functions, and tried making a folder with replacement buttons when a player dies so I can clone it and place it in the last button’s parent.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Code involving the buttons:

local player = game.Players.LocalPlayer
local button1 = workspace.Tower1.WIP.Button1
local button2 = workspace.Tower1.WIP.Button2
local button3 = workspace.Tower1.WIP.Button3

button1.ButtonPart.Touched:Connect(function(hit)
	if player.Character and hit:IsDescendantOf(player.Character) then
		local wall = workspace.Tower1.WIP.Wall1
		wall.Transparency = 0.75
		wall.CanCollide = false
		button1.ButtonPart.BrickColor = BrickColor.new("Bright red")
	end
end)

button2.ButtonPart.Touched:Connect(function(hit)
	if player.Character and hit:IsDescendantOf(player.Character) then
		local wall = workspace.Tower1.WIP.Wall2
		wall.Transparency = 0.75
		wall.CanCollide = false
		button2.ButtonPart.BrickColor = BrickColor.new("Bright red")
	end
end)

button3.ButtonPart.Touched:Connect(function(hit)
	if player.Character and hit:IsDescendantOf(player.Character) then
		local wall = workspace.Tower1.WIP.Wall3
		wall.Transparency = 0.75
		wall.CanCollide = false
		button3.ButtonPart.BrickColor = BrickColor.new("Bright red")
	end
end)

Are you removing this button locally? Is FilteringEnabled? is this script in the players starter gui? is the starter gui script reset on respawn?

Yes I want to remove the button locally. It is. This script is in the starterplayerscripts. And no it is not.

https://gyazo.com/b6728a72154635d9a20fc55fd56015fd

I have mine in the StarterGui so it resets when the player respawns

local player = game.Players.LocalPlayer

game.Workspace["a"].Transparency = 0

game.Workspace["Part"].Touched:connect(function(c)
	game.Workspace["a"].Transparency = 0.5
end)

I just have it automatically reset the transparency of that part and it will go back to normal. The script executes as soon as the player respawns

(Note the second line of my code, where I reset the transparency)

Ok so this is my new code, but it still doesnt work! By the way, I placed the local script into the starter gui.

local player = game.Players.LocalPlayer
local button1 = workspace.Tower1.WIP.Button1
local button2 = workspace.Tower1.WIP.Button2
local button3 = workspace.Tower1.WIP.Button3
local wall1 = workspace.Tower1.WIP.Wall1
local wall2 = workspace.Tower1.WIP.Wall2
local wall3 = workspace.Tower1.WIP.Wall3

wall1.Transparency = 0
wall1.CanCollide = true
wall2.Transparency = 0
wall2.CanCollide = true
wall3.Transparency = 0
wall3.CanCollide = true

button1.ButtonPart.Touched:Connect(function(hit)
	if player.Character and hit:IsDescendantOf(player.Character) then
		wall1.Transparency = 0.75
		wall1.CanCollide = false
		button1.ButtonPart.BrickColor = BrickColor.new("Bright red")
	end
end)

button2.ButtonPart.Touched:Connect(function(hit)
	if player.Character and hit:IsDescendantOf(player.Character) then
		wall2.Transparency = 0.75
		wall2.CanCollide = false
		button2.ButtonPart.BrickColor = BrickColor.new("Bright red")
	end
end)

button3.ButtonPart.Touched:Connect(function(hit)
	if player.Character and hit:IsDescendantOf(player.Character) then
		wall3.Transparency = 0.75
		wall3.CanCollide = false
		button3.ButtonPart.BrickColor = BrickColor.new("Bright red")
	end
end)

Edit: Wait I see my problem…

1 Like

You are the best ikiled thank you!

1 Like

No problem, glad I could help!

You can mark my solution as “solution” if it worked.

1 Like