Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a block that shows who touches it ?

I tried alot and idk why my script isnt working, im trying to make a script that every 145 seconds shows who touches it and type on the screen:The Winners are .... .... .... .... ...; here is my localscript from the gui:

local player = game:GetService("Players").LocalPlayer local touch = workspace.TouchBlock local Touch = workspace.TouchBlocks Touch.Touched:Connect(function(hit) wait(145) if true then do touch.Touched:Connect(function(hit) if hit.Parent == player.Character then

view source

1 script.Parent.Text = "The Winners:".. game.Players.LocalPlayers.Name .."." 2 end 3 end) 4 end end end)

and here it is another localscript from the Starter gui:

local player = game:GetService("Players").LocalPlayer local touch = workspace.TouchBlock

touch.Touched:Connect(function(hit) wait(145) if hit.Parent == player.Character then script.Parent.Ontouchwork.TextLabel.Visible = true wait(5) script.Parent.Ontouchwork.TextLabel.Visible = false end end)

pls, if u can, help me

1 comment

0

ik its annoying being that one guy but you can use lua font btw

1 answer

✓ Accepted answer

LocalPlayer only refers to the player associated with the client that the script is running on. While this does replicate for other players, since LocalPlayer is static but changes depending on the client, it doesn't refer to a group of players (obviously) and there is no property of the Players service named LocalPlayers, either.

A great alternative would be to store every winner in a table, and concatenate them using table.concat, such as in this example:

local values = {1, 2, 3, 4, 5}
-- table.concat() will combine these values into 1 string
local str = table.concat(values, ", ") -- Separate them using ', ', which effectively gives us a list using proper grammar
print(str) -- 1, 2, 3, 4, 5

Apart from the table, ", " is the separator string used to concatenate every value within the table. Concatenation only works on strings (like "Hi") and numbers (like 5), as it will not work for any other data type.

As for getting the players who win the game, don't use LocalPlayer because it's about as unreliable as trying to cut a hard rock using scissors instead of a diamond-edged blade. Getting whoever wins should absolutely be done from the server, and how you get them depends on the system you prefer. Two such examples are:

  • Using Teams to categorize who has won, who is still in the match, and who has lost (if applicable).
  • Using data values to indicate players who have won.

For displaying this data to every player, or any player specified, you will want to use a RemoteEvent and/or a RemoteFunction.

1 comment

0

dude thanks dude ! tyyyy alot !!! tyyyyyyyyyyy

This discussion is preserved as it was. New answers, comments, and votes are closed.