I have tried to detect if a player has a tool to continue the story in a random project im working on and every single attempt has been failure because I want the script to keep checking if the player has the item to continue.

Code Section that i want to work but isn't:

repeat
		if character.Dynamite then
			wait(1)
		player.PlayerGui.Text.Frame.TextLabel.Text = "Dynamite, PERFECT! Now go explode those rocks"
		wait(3)
		player.PlayerGui.Text.Frame.TextLabel.Text = "Behind them is the Great Musuem."
		end
	until character.Dynamite

Full Code:

--The Start
local player = game.Players.LocalPlayer
local character = player.Character
local players = game:GetService("Players")

function onPlayerAdded(plr)
	print(plr.Name .. " joined the game!")
	player.PlayerGui.Text.Frame.TextLabel.Text = "*Snorre* *Snoree*"
	wait(3)
	player.PlayerGui.Text.Frame.TextLabel.Text = "AH! I didn't see you there why must you wake me?"
	wait(3)
	player.PlayerGui.Text.Frame.TextLabel.Text = "YOU DIDN'T MEAN TOO!?"
	wait(3)
	player.PlayerGui.Text.Frame.TextLabel.Text = "YOU JUST CAME IN HERE AND AWOKE ME FROM MY SLUMBER!!"
	wait(5)
	player.PlayerGui.Text.Frame.TextLabel.Text = "Anyways now that you *spit* are here why dont you give me freedom from this place."
	wait(6)
	player.PlayerGui.Text.Frame.TextLabel.Text = "Who am I? I am the 1??????????3???????????????????E?????????????????????????? ?????????????????7??????????????{??????????????????D??????????????`?????????????????????\????????????????????????????????."
	wait(3)
	player.PlayerGui.Text.Frame.TextLabel.Text = "How you ask? I DON'T KNOW, FIND SOMETHING!"
	workspace.Barrier:Destroy()
	print("Get Dynamite")
	repeat
		if character.Dynamite then
			wait(1)
		player.PlayerGui.Text.Frame.TextLabel.Text = "Dynamite, PERFECT! Now go explode those rocks"
		wait(3)
		player.PlayerGui.Text.Frame.TextLabel.Text = "Behind them is the Great Museum."
		end
	until character.Dynamite
end
players.PlayerAdded:Connect(onPlayerAdded)

for _, player in pairs(players:GetPlayers()) do
	onPlayerAdded(player)
end

1 comment

0

Add a .ChildAdded event to character and check the name of the instance that has been added.