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?
Script:
r = game:service("RunService")
local damage = 0
local slash_damage = 0
local attacked = false
sword = script.Parent.Handle Tool = script.Parent
local SlashSound = Instance.new("Sound") SlashSound.SoundId = "http://www.roblox.com/asset/?id=169462048" SlashSound.Parent = sword SlashSound.Volume = 1
local UnsheathSound = Instance.new("Sound") UnsheathSound.SoundId = "http://www.roblox.com/asset/?id=449578741" 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 = Instance.new("BodyThrust") knock.Name = "Knock" knock.force = Vector3.new(0,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 endend end
function tagHumanoid(humanoid, player) local creator_tag = Instance.new("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 = Instance.new("StringValue") anim.Name = "toolanim" anim.Value = "Slash" anim.Parent = Tool end
function swordUp() Tool.GripForward = Vector3.new(-1,0,0) Tool.GripRight = Vector3.new(0,1,0) Tool.GripUp = Vector3.new(0,0,1) end
function swordOut() Tool.GripForward = Vector3.new(0,0,1) Tool.GripRight = Vector3.new(0,-1,0) Tool.GripUp = Vector3.new(-1,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
attack()
wait(0.6)
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)

1 comment
Codeblock maybe plesae thank you?