Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

01game.Players.PlayerAdded:Connect(function(Player)                 
02    Player.CharacterAdded:Connect(function(Character)             
03local stats = Player:WaitForChild("leaderstats")
04local power = stats:WaitForChild("Strength")
05 
06local damage = power*1
07 
08 
09local slash_damage = power*1
10local lunge_damage = power*1.5
0
is "power" a value? KDarren12 705 — 5y
0
in that case, local power = stats:WaitForChild("Strength").Value KDarren12 705 — 5y
0
the object itself is not a value. KDarren12 705 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

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.

1-- LocalScript
2local player = game:GetService("Players").LocalPlayer          
3local stats = player:WaitForChild("leaderstats")
4local power = stats:WaitForChild("Strength")
5local damage = power*1
6local slash_damage = power*1
7local lunge_damage = power*1.5
Ad

Answer this question