Still have questions? Join our Discord server and get real time help.
Log in to vote

How to fix weapon dealing damage without clicking?

Asked by
1itxd 7
7 days ago

I'm creating a game where you fling players off a map with pans. I recently got a pan tool that flings you in the toolbox and it is excellent! The only thing is that it flings players without clicking. Is there anything I can do to fix this?


r = game:service("RunService")

local damage = 0

local slash_damage = 0

local attacked = false

sword = script.Parent.Handle Tool = script.Parent

local SlashSound ="Sound") SlashSound.SoundId = "" SlashSound.Parent = sword SlashSound.Volume = 1

local UnsheathSound ="Sound") UnsheathSound.SoundId = "" UnsheathSound.Parent = sword UnsheathSound.Volume = 1 UnsheathSound.PlaybackSpeed = 0.8

function blow(hit) local humanoid = hit.Parent:findFirstChild("Humanoid") local vCharacter = Tool.Parent local vPlayer = game.Players:playerFromCharacter(vCharacter) local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character if humanoid~=nil and humanoid ~= hum and hum ~= nil then -- final check, make sure sword is in-hand

local right_arm = vCharacter:FindFirstChild("Right Arm") if (right_arm ~= nil) then local joint = right_arm:FindFirstChild("RightGrip") if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then tagHumanoid(humanoid, vPlayer) humanoid:TakeDamage(damage)
if attacked == false then attacked = true
hit.Parent.Torso.CFrame = hit.Parent.Torso.CFrame * >CFrame.Angles(math.rad(180),0,0) local knock ="BodyThrust") knock.Name = "Knock" knock.force =,0,10000) knock.Parent = hit.Parent.Torso game:GetService("Debris"):AddItem(knock, 0.5)
script.Parent.Handle.Hit:Play() end
wait(0.6) attacked = false untagHumanoid(humanoid) end end

end end

function tagHumanoid(humanoid, player) local creator_tag ="ObjectValue") creator_tag.Value = player creator_tag.Name = "creator" creator_tag.Parent = humanoid end

function untagHumanoid(humanoid) if humanoid ~= nil then local tag = humanoid:findFirstChild("creator") if tag ~= nil then tag.Parent = nil end end end

function attack() damage = slash_damage SlashSound:play() local anim ="StringValue") anim.Name = "toolanim" anim.Value = "Slash" anim.Parent = Tool end

function swordUp() Tool.GripForward =,0,0) Tool.GripRight =,1,0) Tool.GripUp =,0,1) end

function swordOut() Tool.GripForward =,0,1) Tool.GripRight =,-1,0) Tool.GripUp =,0,0) end

Tool.Enabled = true

function onActivated()

if not Tool.Enabled then return end

Tool.Enabled = false

local character = Tool.Parent; local humanoid = character.Humanoid if humanoid == nil then print("Humanoid not found") return end



Tool.Enabled = true end

function onEquipped() local plr = game.Players.LocalPlayer local humanoid = plr.Character.Humanoid

UnsheathSound:play() end

script.Parent.Activated:connect(onActivated) script.Parent.Equipped:connect(onEquipped)

connection = sword.Touched:connect(blow)

Codeblock maybe plesae thank you? Gooncreeper 79 — 7d

1 answer

Log in to vote
Answered by 6 days ago
Edited 6 days ago

just add a boolean value that is false when your pan isnt activated and true when it is activated and add an if statement saying if its true then it will do its thing

can you maybe send a script of what it would look like? 1itxd 7 — 5d

Answer this question