Value not change even if the string value are the same

SOmeone found a way to use the click detector even when a tool is equipped so I used it, I made a remote event (client - server) that change the value of opened to true if used with a certain key color, but it somewhat doesnt change the value even if the string are the same

local script
local Tool = script.Parent
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()

ocal colorString = "Yellow"

Tool.Activated:Connect(function()
	if Tool.Equipped then
		if Mouse.Target and Mouse.Target:FindFirstChild("ClickDetector") then
			if (Tool.Handle.Position - Mouse.Target.Position).Magnitude <= Mouse.Target.ClickDetector.MaxActivationDistance then
 				game.ReplicatedStorage.KeyOpen:FireServer(tostring(colorString))
			end
 		end
 	end
end)
server script
local OpenValue = script.Parent.Opened

game.ReplicatedStorage.KeyOpen.OnServerEvent:Connect(function(color)
	if color == script.Parent.KeyColor.Value then
		OpenValue.Value = true
	end
end)

remote event name: KeyOpen
image
color value inside tool: Yellow
key color inside keyhole: Yellow (I

Something like this

Opened = script.Parent.Opened.Value;

KeyColor = script.Parent.Tip.Color;
RequiredKeyColor = Color3.fromRGB(255,255,255);


game.ReplicatedStorage.KeyOpen.OnServerEvent:Connect(function()
	if KeyColor == RequiredKeyColor and Opened ~= true then
		Opened = true
	end
end)

the first argument on OnServerEvent is the player that ran the remote
I think this is your issue, here’s a fix

game.ReplicatedStorage.KeyOpen.OnServerEvent:Connect(function(Player, color)
	if color == script.Parent.KeyColor.Value then
		OpenValue.Value = true
	end
end)
2 Likes

oh yea I always forgot about the player lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.