Guys, I've been trying to find a solution to this problem for some time and I don't find that somewhere, so I would like to count on your help.
As described in the title: How could I make the debounce feature only act for the person who stepped on the block (in my case)? Here's my script (after thousands of changes):
local brick = script.Parent local brickTouchedEvent = game.ReplicatedStorage.Events.BrickTouched local debounce = false brick.Touched:Connect(function(hit) if not debounce then debounce = true local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.PlayerGui.Objetivos.TutorialGUI.Objetivo.Text = "Pule pelas plataformas até chegar no terceiro CHECKPOINT." brickTouchedEvent:FireClient(player) print(player.Name.." passou pelo segundo checkpoint") debounce = true -- I want that the player can't activate it again after activate it once -- end end)
And, to be sure, the form of activate the GUI when a player steps on the block is correct? My idea is to make when the player passes through an area of the game this gui activate and tell you what to do next, here's my script:
brickTouchedEvent.OnClientEvent:Connect(function() openClose() -- This is a functions of my code that I want to run when the player touch the part with the script -- end)
(In my "Replicated Storage" has a remote event as shown in the first script.)
Thank you very much for your attention. Eduardo
Well here is the thing. There is a difference between client and servers (local script vs script). Here are some quotes from the roblox API that will help you understand.
Roblox uses the client-server model, a common framework for multiplayer games. Whenever you play a Roblox game, your personal computer, phone, tablet, or game console becomes a client. Every other unique player in the game is also a client.
All clients (players) in the game are connected to a powerful Roblox computer known as a server. The server is like the game manager — it makes sure that every player is seeing and experiencing the game world the same as every other player.
This code is in a script, which runs on the server. That means if one steps then all will recieve. The way to write something on the client is by using remote events. This allows you to run client code using a server script, and it is what you are asking for. This article defines it very well!
Edit: The problem with your code is that you are Firing the event when the part is touched. When the part is touched you first have to place an if statement detecting the player and then do something with your remotes. All local script code should be on the other end of the event. The link above will show you how to properly handle Remote. Also, for future reference: it is good to give us all the code. You need to let us know what the closeOpen() function is