so how the script now looks? The only problem now is the incorrect damage, right?
local RS = game:GetService("ReplicatedStorage")
local AddWoodEvent = RS.AddWood
local function SearchForAxe(Container) -- Move local function outside of connection
for _, Item in Container:GetChildren() do
if not Item:IsA("Tool") or Item.Name ~= "Axe" then continue end
return Item
end
end
AddWoodEvent.OnServerEvent:Connect(function(Player) -- (A) Were you supposed to add "Wood" as a parameter
local Character = Player.Character or Player.CharacterAdded:Wait()
local Axe = SearchForAxe(Character) -- (B) Does the character have multiple axes at once?
if not Axe then return end -- Player has no axe equipped
local Damage = Axe:WaitForChild("damage", 5)
if not Damage then warn("Axe has no damage value") return end
local PlayerAxes = Player:WaitForChild("axes", 5)
if not PlayerAxes then warn("Player has no axes") return end
local twxWood = PlayerAxes:FindFirstChild("twxWood", 5)
print(Damage.Value)
wood.Value += Damage.Value * (twxWood.Value and 2 or 1) -- Multiply by 2 if twxWood, otherwise 1
-- (A) Unknown 'Wood'
end)
what about set damage as 0 at the beggining?
AddWoodEvent.OnServerEvent:Connect(function(Player) -- (A) Were you supposed to add "Wood" as a parameter
local DamageValue = 0
local Character = Player.Character or Player.CharacterAdded:Wait()
local Axe = SearchForAxe(Character) -- (B) Does the character have multiple axes at once?
if not Axe then return end -- Player has no axe equipped
DamageValue = Axe:FindFirstChild("damage", 5).Value
if not DamageValue then warn("Axe has no damage value") return end
local PlayerAxes = Player:WaitForChild("axes", 5)
if not PlayerAxes then warn("Player has no axes") return end
local twxWood = PlayerAxes:FindFirstChild("twxWood", 5)
print(DamageValue)
wood.Value += Damage * (twxWood.Value and 2 or 1) -- Multiply by 2 if twxWood, otherwise 1
-- (A) Unknown 'Wood'
end)
it still prints the same number as the first axe
And set it to 0 again at the end, what will it print out
It is still printing the same number as the first axe
And how does the firingevent script look like?
game.ReplicatedStorage.AddWood:FireServer()
DamageValue = Axe:FindFirstChild("damage")
if not DamageValue then warn("Axe has no damage value") return end
having a set damage value wouldnât change the orginal axeâs value
(it would probably only be used as a âdefaultâ damage value)
after removing the extra stff it is saying attempt to preform arithmetic (mul) on isntence and number
wood.Value += DamageValue * (twxWood.Value and 2 or 1) -- Multiply by 2 if twxWood, otherwise 1
because DamageValue is a ValueBase (instance)
add a .Value to the end
wood.Value += DamageValue.Value * (twxWood.Value and 2 or 1) -- Multiply by 2 if twxWood, otherwise 1
edit: iâm taking a while to respond because iâm playing l4d2
it still stays the same value as the first axe
Where is it? I dont see any localscript inside the tool on the video showed earlier
it is in a localscript and the localscript is the axe
Can you run play and check damage value within the axe on the server side?
Maybe something changes the value of the other axe to the value of previous axe.
Are the values preset or are they changed through a script?
like in the explorer tab or print()
explorer. Next to stop button there will be âcurrent: clientâ, click it to get to serverâs pov
ok, so it does change, but when i remove the axe it only does it client side not serverside, but i dont think that should be a problem saying we are checking it on the character
so on server side the damage in both axes is 20?