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

Can anyone check if the script I wrote is correct?

I have an error that says

expected identifier, got ':'

can anyone check why??

This is a Script, not a local script.

-- Made By RainbowBeastYT


local tool = script.Parent

local speedboost =1.25

local handle = tool:WaitForChild("Handle")
local event = tool:WaitForChild("RemoteEvent")
local damage = 100
local lastclick = tick()


local equipped = true
local character = tool.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local humanoid = character:FindFirstChild("humanoid")
local targethumanoid:TakeDamage(damage)
	

tool.Equipped:Connect(function()
	lastclick = tick()
	if humanoid then
		humanoid.Walkspeed = humanoid.Walkspeed * speedboost
	else
		character = nil
	end
end)

tool.Unequipped:Connect(function()
	if humanoid then
		humanoid.Walkspeed = humanoid.Walkspeed / speedboost
	end
	character = nil
	humanoid = nil
end)


handle.Touched:Connect(function(hit)
	if equipped and character and humanoid and humanoid.health > 0 and hit and not hit:isDescendantOf(character) then
		local targethumanoid = hit.Parent:FindFirstChild("Humanoid")
		if targethumanoid and targethumanoid.Health > 0 and not hithumanoid(targethumanoid) then
			local hithumanoid(targethumanoid) = true
			targethumanoid:TakeDamage(damage)
		end
	end
end)

tool.Activated:Connect(function()
	local clickdelta = tick() - lastclick
	if clickdelta > 1 then
	lastclick = tick()
	local hithumanoid = {}
	if clickdelta < slashtime * combowindow then
	if player then
		end
	end
end)

Can anyone please help!

5 comments

0

There's no script.

0

now theer is

0

I post it by accident, now I finish the post

0

Which line does it error at?

0

wait about line 18 there might be a problem there?

1 answer

The problem is that you began declaring a variable, but never named the variable anything on line 18.

You said

local targethumanoid:TakeDamage(damage)

But targethumanoid is not a variable! Also, TakeDamage has the type void, so it will not return anything. If your intention is to hurt the player by a certain amount of health, you don't need to use the keyword local.

All you have to do is remove that line because it seems it's not important in the context of the script. If you want the player to immediately take damage as soon as the script runs, then sure, keep it but change it to humanoid:TakeDamage(damage).

Also, the line where you say

local humanoid = character:FindFirstChild("humanoid")

Make sure to look for Humanoid with a capital H.

local humanoid = character:FindFirstChild("Humanoid")

Hope this helps! :)

1 comment

0

I already fix it but thx anyway

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