I am trying to make a script so when a person spawns in a map, they will hit a non-collidable but touchable part (as they spawn) and activate a UI text saying the map’s name at the bottom.
Problem is, when I try to do this, it just straight up does not work. No errors in the output.
This may be a very dumb mistake because I’m not good at scripting.
You are firing the same code over and over everytime the part is touched, with the result being it never starting, without errors.
I would suggest deleting the part right after Touched is fired, so it runs once only.
It should work if the script isn’t a child of the “touch” part, iirc.
Also try setting off the ui change manually in your script, without waiting for the touched event, because that way you know if it is the script or the touching that doesn’t work. You could add a debounce too, with the same effect as what someone said above me
EDIT: Is the touching the part required? because if you just want to play the text when they join, you can do this:
Players = game:getService("Players")
Players.PlayerAdded:Connect(function()
--your code, without the part touching event
end)
Another note, I think we are supposed to use task.wait() instead of wait() but I am not 100% sure.
I think I might know the problem. I think you need to be coding the gui on the client? Or at least referencing the gui as the client. Right now I think you are just changing it in starter gui which wont make a difference for people in the game. Is your script in serverscriptserice?
EDIT: I just realized, @WorkPro2007 said what i said above further up, I didnt even notice! You will need to be coding it so that you are changing it in playergui, the client where the gui is, not starter gui. Starter gui gets replicated to any new players who join, but the players see the gui in playergui
local Players = game:GetService("Players")
part = game.Workspace:WaitForChild("touch") -- change this to whatever/wherever your part is
part.Touched:Connect(function(hit)
local character = hit.Parent
if character then
player = Players:GetPlayerFromCharacter(character)
else
warn("character not found")
end
if player then
part:Destroy()
local ui = player.PlayerGui
ui.MapTitle.TextLabel.Text = "Map_Test1"
ui.MapTitle.TextLabel.TextTransparency = 1
repeat
wait()
ui.MapTitle.TextLabel.TextTransparency = ui.MapTitle.TextLabel.TextTransparency - 0.01
until
ui.MapTitle.TextLabel.TextTransparency == 0
wait(1)
repeat
wait()
ui.MapTitle.TextLabel.TextTransparency = ui.MapTitle.TextLabel.TextTransparency + 0.01
until
ui.MapTitle.TextLabel.TextTransparency == 0
wait(0.01)
else
warn("player not found")
end
end)
Ok, it half works. For some reason it is fading in (very slowly) but not fading out before that. So let me try to fix it and i will edit the code above as I do.