I'm decently new to scripting and I made a game where you find things around the map and once you touch them a Text Lable pops up saying you found it but if you touch it again it will say you already found it. But if somebody else in the server touches it and then you touch it it will say you already found it because I'm using a script that changes the text when somebody touches it is there a way to get around this? Here is my code.
Popup = script.Parent.ScreenGui Ready = true function onTouch(hit)
01 | local h = hit.Parent:FindFirstChild( "Humanoid" ) |
02 | if h ~ = nil and Ready = = true then |
03 | Ready = false |
04 | local plyr = game.Players:FindFirstChild(h.Parent.Name) |
05 | local c = Popup:clone() |
06 | c.Parent = plyr.PlayerGui |
07 | wait( 3 ) |
08 | c:remove() |
09 | wait( 1 ) |
10 | Ready = true |
11 | script.Parent.Touched:Connect( function () |
12 | script.Parent.RR.TextLabel.Text = "You Already Found This Blank" |
13 | script.Parent.RR.TextLabel.TextScaled = true |
14 | end ) |
15 | end |
end
script.Parent.Touched:connect(onTouch)
Edit:Pretend the code thats out of the script thingy is in it lol
Hello! For simplicity, I recommend changing the touched function to a proximity prompt or click. That way, just say:
01 | This is a server script btw |
02 | — insert a boolean value thats false |
03 | — insert a string value that is blank |
04 | local winner = game.Workspace.Winner |
05 | Local done = Game.Workspace.Done |
06 | Local Prompt = script.Parent.Prompt |
07 | If done.Value = = true then |
08 | Prompt.Triggered:Connect( function (Plr) |
09 | winner = plr |
10 | else |
11 | Warn(plr..”is not the winner!”) |
12 | end |
—Local Script In starter gui—-
01 | local winner = game.Workspace.Winner |
02 |
03 | Local done = Game.Workspace.Done |
04 | Local LocalPlr = game.Players.LocalPlayer |
05 | repeat |
06 | wait() |
07 | If done.Value = = true then |
08 | If winner = = LocalPlr then |
09 | script.Parent.WinnerScreen.Enabled = true |
10 |
11 | script.Parent.WinnerScreen.TextBox.Text = “You did it!” |
12 |
13 | Else |
14 | script.Parent.WinnerScreen.TextBox.Text = winner..” has already found this!” |
15 | script.Parent.WinnerScreen.Enabled = true |
16 | Until 1 = = 2 |
Tell me if this won’t work! Thanks! -Leo
I'm answering instead of replying so you'll see it lol but i get that it would be much simpler if i used a click or proximity prompt but I'm trying to get a style similar to what find the chomiks is doing and it would be a lot harder to hide things in walls and such if i were to use a proximity prompt. Could i do it with a touched event?