Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't this power multiplier working?

So I'm making a Roblox game where you collect orbs that give you 1 power (a leader stats value), and a punch tool where whenever you punch, the punch strength goes up by 1 every power you get, so basically 1 power = 1 extra damage per hit, the only problem is after the remote event is triggered, for some reason my multiplier isn't working, can someone please help!

Local script (working but just for extra detail):

Player = game.Players.LocalPlayer
repeat wait() until Player.Character
Character = Player.Character
mouse = Player:GetMouse()
Tool = script.Parent
multiplier = 1

Enabled = true

Tool.Activated:Connect(function()
	if Enabled == true then
		script.Function:FireServer(game.Players.LocalPlayer, "Combat", multiplier, Player.leaderstats.Power.Value, Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-2).p)
	end
	
end)

Script (the thing I'm having a problem with):

Enabled = true



script.Parent.OnServerEvent:Connect(function(Player, Action, m,Power, V1)
	local c = Player.Character
	local dmg = c.Humanoid.Health = player.Character.Humanoid.Health - Power * m
	if Enabled == false then return end
	if Action  == "Combat" then
		local Track = Instance.new("Animation")
		Track.AnimationId = "rbxassetid://6024898273"
		local Anim = c.Humanoid:LoadAnimation(Track)
		Anim:Play()
		local Region = Region3.new(V1-Vector3.new(2,2,2),V1+Vector3.new(2,2,2))
		local RTable = workspace:FindPartsInRegion3(Region, nil, 20)
		for i,v in pairs(RTable) do
			if v.Parent:findFirstChild("Humanoid") and v.Parent:findFirstChild("Deb") == nil and v.Parent ~= c then
				local Deb = Instance.new("BoolValue", v.Parent)Deb.Name = "Deb"
				game.Debris:AddItem(Deb,0.2)
				v.Parent.Humanoid:TakeDamage(dmg)
				end
			end
		end
	end
end)

Output:

12:59:58.521 - Players.hoth7.Backpack.Tool.Main.Function.Script:7: Expected identifier when parsing expression, got '='

The line the problem is in is line 7. Help appreciated!

1 comment

0

The answer may seem obvious, but what identifier do they want me to put?

2 answers

Notice how on line 7 you have:

local dmg = c.Humanoid.Health = player.Character.Humanoid.Health - Power * m

This is essentially two statements since you have two equals signs. I'm not exactly sure on the math you were trying to do- although if it two separate assignments I recommend using two statements by splitting the line to two declarations, or if your mathematical intent was closer to using addition you can change that sign.

--version 1
local dmg = c.Humanoid.Health 
local whatever = player.Character.Humanoid.Health - Power * m

--version 2
local dmg = c.Humanoid.Health + player.Character.Humanoid.Health - Power * m

Seems like a simple typo to me. Anyways hope that helps.

EDIT:

On further inspection it looks like you might just have a repeat in context, in which case you can also just use this.

--version 3
local dmg = c.Humanoid.Health - Power * m

1 comment

0

13:25:48.139 - Players.hoth7.Backpack.Tool.Main.Function.Script:7: attempt to perform arithmetic (mul) on number and string. For some reason its not working, and I don't know what the output is saying, please help!

pretty simple reason, never fire who the player is in the remote event, roblox does that automatically for you so it would look like this

script.Function:FireServer("Combat", multiplier, Player.leaderstats.Power.Value, Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-2).p)

This discussion is preserved as it was. New answers, comments, and votes are closed.