I have a Tool Sign that supposedly edits for one person only who has it, apparently whenever I enter it goes on edits for all of the signs that everyone have.
Can anyone point out where did I went wrong?
This is how it looks for the Tool itself.
This is where the GUI is for Local Player:
The script is just small, but I use a RemoteEvent. I also used RemoteFunction which works as well however sends to different people that owns the sign.
Server Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Chat = game:GetService("Chat")
local Event = ReplicatedStorage:WaitForChild("ChangeTextSign")
Event.OnServerEvent:Connect(function(player, text)
local TextSign = script.Parent
local Filter = Chat:FilterStringForBroadcast(text, player)
TextSign.Text = Filter
end)
localScript:
local rs = game:GetService("ReplicatedStorage")
local Event = rs:WaitForChild("ChangeTextSign")
local SignText = script.Parent.Parent.TextBox
SignText.FocusLost:Connect(function()
local Text = SignText.Text
Event:FireServer(Text)
end)
You could just put the RemoteEvent in the tool itself only, or you can do a check on the server to see if the player that has equipped the sign is the same as the player who sent the event. This can be done as so:
local tool = script.Parent -- or .Parent, whereever tool is basically.
-- Event recieved function
local ourPlayer = game.Players:GetPlayerFromCharacter(tool.Parent)
if player == ourPlayer then
-- Run the TextSign changes.
I tried doing the Check on the Server, and it didn’t work. I tried putting it inside the OnServerEvent function.
Also, as for putting the RemoteEvent inside the tool itself, won’t that take much longer to detect where the heck the Remote Event will be? If its possible, can you tell me how it is?
For the most parts, this is what I did inside the server script
Event.OnServerEvent:Connect(function(player, text)
print("Detecting player...")
if player == MainPlayer then
print("Player"..MainPlayer.."Detected!")
local TextSign = script.Parent
local Filter = Chat:FilterStringForBroadcast(text, player)
print("Filtering...")
TextSign.Text = Filter
print("Filtered!")
end
end)
it only prints Detecting Player and it doesn’t proceed any longer than that
apparently, it didn’t took me that long to alter the Script for putting the RemoteEvent inside the Tool, I’ll test this out with out people in a bit and see if it still affects others. Thanks for the help, will post here again in a bit.
It seems that you misunderstood the issue. Here, let me break it down for you;
OP is having an issue where the remote event fires unwantingly to the rest of the sign tools in other player’s inventory thus causing those signs to also get altered. Setting the TextEditable property to false would do nothing.
That’s good to hear. Let me know what happens and I’ll try to assist you.
If it works then please mark one of our posts as the solution so people know that this post has been solved. Maybe mark mine as the solution or SkrubDaNub’s post.