I am making a combat script and am trying to get a number-value from ServerStorage, which will be the damage done to the player.
The reason why the number-value is in ServerStorage , is because the value gets updated when you add a point in strength -- I did this to prevent any exploiters from being able to adjust the value.
local strength = game.ServerStorage.Strenght.Value
--- for i,v in pairs(game.Workspace:GetChildren()) do
local m = (v:IsA("Model") and v) or nil
if m and m:FindFirstChild("Enemy") and m ~= character then
if (character.HumanoidRootPart.Position - m.HumanoidRootPart.Position).Magnitude <= 5 then
print("humanoid nearby")
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://131237241"
sound.Parent = Player.Character.HumanoidRootPart ---HERE
sound:Play()
game.Debris:AddItem(sound,1)
local sound2 = Instance.new("Sound")
sound2.SoundId = "rbxassetid://131237241"
sound2.Parent = m.HumanoidRootPart
sound2:Play()
game.Debris:AddItem(sound2,1)
local hiteffect = replicatedStorage:WaitForChild("HitEffect"):Clone()
hiteffect.CanCollide = false
hiteffect.Anchored = true
hiteffect.CFrame = m.HumanoidRootPart.CFrame
hiteffect.Parent = workspace
game.Debris:AddItem(hiteffect,0.4)
local hit = Instance.new("BoolValue",m)
hit.Name = "Hit"
game.Debris:AddItem(hit,0.7)
m.Enemy:TakeDamage(strength) **here is the problem **
spawn(function()
m.Enemy.WalkSpeed = 1
m.Enemy.JumpPower = 1
wait(1)
m.Enemy.WalkSpeed = 16
m.Enemy.JumpPower = 50

2 comments
this will not work if you are using a local script as serverstorage can only be accessed from the server, also please dont forget "end end" at the end of your code
You spelt strength ("Strenght") wrong