Need Help Figuring Out Why I'm getting no error But script doesn't work

Tool.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:Connect(function()
		local leaderstats = player.leaderstats
		local goldStat = leaderstats and leaderstats:FindFirstChild("Strength")
		if goldStat then
			goldStat.Value = goldstat.Value + 10
		end
	end)
end)``````

You could just also do this entirely in 1 script without having to use RemoteEvents, just do this all in 1 server script with referencing some parents:

local Tool = script.Parent

Tool.Activated:Connect(function()
    local Character = Tool.Parent
    local Player = game.Players:GetPlayerFromCharacter(Character)

    if Player then
        Player.leaderstats.Strength.Value += 10
    end
end)

You can just easily reference the Player by getting the Tool’s 2 Parents & using the GetPlayerFromCharacter() function when the Tool gets activated, no need for RemoteEvents

but dont you need to change values from the server side?

That’s what you can literally do

You can reference it as a Server Script easily, there’s no need to add the addition of having a RemoteEvent in the play

Upon equipped, the Tool’s Parent would be in the Player’s Character

i dont think a quite understand what your saying

is this in a server script or local script

Server Script

image

It doesn’t matter what script you use, you can get the Player both ways

local Tool = script.Parent

Tool.Activated:Connect(function() --Already the Tool's Parent would be in the Player's Character, so there's no need to have a RemoteEvent
    local Character = Tool.Parent
    local Player = game.Players:GetPlayerFromCharacter(Character)

    if Player then
        Player.leaderstats.Strength.Value += 10
    end
end)
1 Like

oh i understand what you mean, i already know this but idk if the @OP 's script is server or client i will tell to change the script to server

It still wouldn’t matter regardless

It’s better to use a Activated Event detect when to give the Player the Gold Stats instead of having to get the Mouse’s Instance via the Equipped parameter of the Tool (Which would be considered Legacy or old)

1 Like