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

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

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.

-- 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
Ad

Answer this question