Hey scriptinghelpers, I'm working on a script that changes the BrickColor of my tools handle. I was using something similar in a local script but, the problem with that was it didn't change the color for other than the player holding the tool. I don't really know how else to word this question, sorry about that. I need the color to be visible to all players to know who touched it last.
I'm considering using ServerScriptStorage but, I don't know how I would find the player who has the tool. There would be 10 players if my server was full.
This is a script inside of a handle inside of a tool. BrickColorValue in ReplicatedStorage (this is so that I can read always read it since I don't know how to find the player who has the tool, tool name is "Ball")
local value = game.ReplicatedStorage:FindFirstChild("BrickColorValue") value.Changed:Connect(function(new) script.Parent.BrickColor = value.Value end)
My other script was a local script inside of the tool.
while true do wait(1) if game.ReplicatedStorage.StringValue.Value == "Equipped" then script.Parent.Handle.BrickColor = game.ReplicatedStorage.BrickColorValue.Value--this value is constantly changing to whoever touched it last going by there team color I have a separate script for this
Thanks for the help in advance! I'm just kinda confused, I actually wasn't going to ask this question since it's so simple. Just can't seem to figure it because, everything looks perfect to me. In other ways I know it would work but, it's not.
ok so uh heres what you can do to reference the local player and its character in a server script inside a tool's handle.
local player = nil -- for now it is nil local character = nil local handle = script.Parent local tool = handle.Parent local BrickColor = game:GetService("ReplicatedStorage"):FindFirstChildWhichIsA("BrickColorValue") -- ima just search it by its class name. function playerref() if game:GetService("Players"):GetPlayerFromCharacter(tool.Parent) ~= nil then -- in case the weapon is equipped player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent) character = tool.Parent end if tool.Parent:IsA("Backpack") then -- yes, backpack is a separate class player = tool.Parent.Parent -- in case the weapon is not equipped character = tool.Parent.Parent.Character end end playerref() -- do the function once tool:GetPropertyChangedSignal("Parent"):Connect(playerref) -- do it everytime the tool's parent changes, to prevent some bugs (?) function colorchange() handle.BrickColor = BrickColor.Value end colorchange() BrickColor:GetPropertyChangedSignal("Value"):Connect(colorchange)