Hello everyone, I created a script but here’s the catch, I have a problem with it, you give me this error forever when I have 100 strength and get on it Workspace.Endurance.Script:22: attempt to perform arithmetic (mul) on number and string - Server - Script:22
local playersInside = {}
script.Parent.Touched:Connect(function(hit)
if hit.Name ~= "HumanoidRootPart" then return end
local player = Player:GetPlayerFromCharacter(hit.Parent)
if not player then return end
local strength = player:FindFirstChild("Strength")
local eMulti = player.eMulti.Value
local class = player.leaderstats.Class.Value
if not strength or strength.Value < 100 then return end
table.insert(playersInside, player)
while table.find(playersInside, player) do
wait(2)
if not table.find(playersInside, player) then return end
local endurance = player:FindFirstChild("Endurance")
if endurance then
endurance.Value = endurance.Value + 1000 *class*eMulti
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
if hit.Name ~= "HumanoidRootPart" then return end
local player = Player:GetPlayerFromCharacter(hit.Parent)
if not player then return end
local playerIndex = table.find(playersInside, player)
if playerIndex then
table.remove(playersInside, playerIndex)
end
end)```
local Player = game:GetService("Players")
local playersInside = {}
script.Parent.Touched:Connect(function(hit)
if hit.Name ~= "HumanoidRootPart" then return end
local player = Player:GetPlayerFromCharacter(hit.Parent)
if not player then return end
local strength = player:FindFirstChild("Strength")
local eMulti = player.eMulti.Value
local class = player.leaderstats.Class.Value
if not strength or strength.Value < 100 then return end
table.insert(playersInside, player)
while table.find(playersInside, player) do
wait(2)
if not table.find(playersInside, player) then return end
local endurance = player:FindFirstChild("Endurance")
if endurance then
local endu = tonumber(endurance.Name)
endurance.Value = endurance + 1000 *tonumber(class)*tonumber(eMulti)
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
if hit.Name ~= "HumanoidRootPart" then return end
local player = Player:GetPlayerFromCharacter(hit.Parent)
if not player then return end
local playerIndex = table.find(playersInside, player)
if playerIndex then
table.remove(playersInside, playerIndex)
end
end)```
Just remove the class from this line here:
endurance.Value = endurance.Value + 1000 *class*eMulti
So should be
endurance.Value = endurance.Value + 1000*eMulti
You cannot convert a string into a number. The only time you can convert a string into a number is if the string only contains numbers else it’ll just return nil
You can go the other way, I already have one main script, but I need to combine this script and the other, but I don’t know how to connect without errors