Is there anything wrong with this script?

In this script I am trying to make a checkpoint decoration for an obby.
I tried my best to make a script, but it doesn’t work and the output doesn’t show anything.
image
Thank you to those who comment.

3 Likes

Add a print at the top of the function so you can see if the function is firing at all.
If it is, you need to figure out why Humanoid isn’t being found. If it isn’t, is this a LocalScript?

You can’t check for the humanoid what if some other part touched the part put the variable check in an if as well

If it’s not printing anything, then there certainly is something wrong. Are you sure you are connecting the right part and have you touched it?

Also, game.StarterGui.Checkpoint.Frame.Visible stuff will only affect players that are getting copied the GUI. With this code you won’t affect the ui at all to any players. You need to get player.PlayerGui.Checkpoint…

  1. You did a error in FindFirstChild, you wrote the f small replace findFirstChild with FindFirstChild but its also working with that.

  2. You are trying to change something in StarterGui so i thing this is happening in Localscript, if your Localscript is in Workspace it will not work, in your script you have script.Parent so that means its in the Workspace, put the Localscript to StarterGui and change script.Parent to your Part.

  3. If its a Server Script the Frame will not change when u use StarterGui, then u need to use RemoteEvent or u can change the Frame through the PlayerGui. But i thing its not a ServerScript because its not printing true.

wait() is decrapted, use task.wait()

do: game.StarterGui.Checkpoint.Frame.Visible = not game.StarterGui.Checkpoint.Frame.Visible

No its not Wait() is decrapted but not wait()

When changing a players gui, Never use game.StarterGui.

game.StarterGui is just a instance that automatically loads the guis into the Players Gui.
Changing something from Startergui will not replicate to any other players.

Instead, do this:

local plr = -- your directory
plr.PlayerGui.Checkpoint.Frame.Visible

No matter the capitalization, it’s still depreciated.

Then tell me what this is:

Wait() is also working but its also depreciated, but thats not the Theme of this Post

To all who are wondering, this is a local script located in workspace. I honestly do not see anything wrong with this script because I took a brake for a while and forgot most of my scripting skills.

There is findFirstChild small but its also working with that he used ServerScript or Localscript in wrong Place

I just put a print command at the very beginning of the script, and it seems it has not worked. Is this something to do with the local script itself?

Put the localscript to ServerGui

make sure it’s script and not a localscript…

local function OnTouched(Part)
	local Humanoid = Part.Parent:FindFirstChild("Humanoid")
	if Humanoid then
		local Player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
		script.Parent.BrickColor = BrickColor.new("Lime green")
		Player.PlayerGui.Checkpoint.Frame.Visible = true
		task.wait(1)
		script.Parent.BrickColor = BrickColor.new("Really red")
		Player.PlayerGui.Checkpoint.Frame.Visible = false
	end
end

script.Parent.Touched:Connect(OnTouched)

Since the output doesn’t show anything, we can say the touch never fired as the print should have printed. Try the script with the collision on. If it works, use collision groups to disable the collision between Players and the Part.

(Mark as Solution if this works)

part.CanCollide = true -- set this through the Explorer

(just saying lol)

Depreciated means it still exists (and functions), but it is not recommended for use, and it will be replaced with something else, there is a chance the depreciated one will be deleted off of the programming language.

Yes

1 Like

Would that script apply to all players in the game or just the one player? Im saying this because you said I need to change my localscript into a script.

it’s only getting the player who touched it…

1 Like