Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why wont my sword script connect to the strength leaderstat and multiply against it to do damage?

This isn't my whole script but its the part that doesnt work

game.Players.PlayerAdded:Connect(function(Player)                  
    Player.CharacterAdded:Connect(function(Character)              
local stats = Player:WaitForChild("leaderstats")
local power = stats:WaitForChild("Strength")

local damage = power*1 


local slash_damage = power*1
local lunge_damage = power*1.5

3 comments

0

is "power" a value?

0

in that case, local power = stats:WaitForChild("Strength").Value

0

the object itself is not a value.

1 answer

✓ Accepted answer

So your problem is just simple client/server boundary stuff. The server can't access the client, and the client can't access the server. So for this script you want to put it a local script. Here is an example on how I would modify it to make it work.

-- LocalScript
local player = game:GetService("Players").LocalPlayer           
local stats = player:WaitForChild("leaderstats")
local power = stats:WaitForChild("Strength")
local damage = power*1 
local slash_damage = power*1
local lunge_damage = power*1.5

This discussion is preserved as it was. New answers, comments, and votes are closed.