#I need help on a remote event thing

1 messages · Page 1 of 1 (latest)

twin moth
#

Im trying to make it so I gain strength each time I click a specific tool I dont know the error can someone help me? Heres the Client: ```local player = game.Players.LocalPlayer
local replicatedstorage = game:GetService("ReplicatedStorage")
local LiftRemote = replicatedstorage.Remotes:WaitForChild("LiftRemote")

function Lift(toolName, value)
local tool = player.Backpack:FindFirstChild(toolName) or player.Character:FindFirstChild(toolName)

if tool and tool:IsA("Tool") then
    tool.Activated:Connect(function()
        LiftRemote:FireServer(toolName, value)
    end)
end

end

Lift("Pencil", 1)
And heres The Server: local replicatedstorage = game:GetService("ReplicatedStorage")
local LiftRemote = replicatedstorage:WaitForChild("Remotes"):WaitForChild("LiftRemote")

LiftRemote.OnServerEvent:Connect(function(player, toolName, value)
local leaderstats = player:FindFirstChild("leaderstats")
local strength = leaderstats and leaderstats:FindFirstChild("Strength")

if strength and typeof(value) == "number" then
    strength.Value += value
end

end)