| |
|
»
»
|
|
| |
Re: Is there a way to make a click attack a hotkey attack?
|
|
|
|
| 27 Nov 2015 10:06 AM |
| I need to know how. because I have these attacks, but I want them to be for hotkeys. anyone know how i can convert it? |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:08 AM |
| Change the MouseButton1Click to InputBegan and check which key is being pressed. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:11 AM |
I don't see a mousebuttondown1 in the beggining. Instead I see something like this? Idk if this has anything to do with it
function CreateTag(Attacker, VictimHumanoid) for i, v in pairs(VictimHumanoid:GetChildren()) do if v.Name == "creator" then v:Remove() end end Tag = Instance.new("ObjectValue") Tag.Parent = VictimHumanoid Tag.Name = "creator" Tag.Value = Attacker end
Activated = false
function Attack(mouse)
if not Activated then
Activated = true
local player = game.Players.LocalPlayer if player == nil then return end mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
local pos = mouse.Hit.p |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:12 AM |
| Is this the entire script? |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:13 AM |
No, Want me to put the whole script up instead?
|
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Nov 2015 10:13 AM |
Part 1 of 2. ______________________________________________________________________________________
Tool = script.Parent Backpack = Tool.Parent Me = Backpack.Parent PlayerGui = Me.PlayerGui char = Me.Character humanoid = char.Humanoid torso = char.Torso head = char.Head leftarm = char["Left Arm"] rightarm = char["Right Arm"] leftleg = char["Left Leg"] rightleg = char["Right Leg"] neck = torso["Neck"] rightshoulder = torso["Right Shoulder"] leftshoulder = torso["Left Shoulder"] righthip = torso["Right Hip"] lefthip = torso["Left Hip"]
neckC0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0) neckC1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0) leftshoulderC0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0) leftshoulderC1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0) rightshoulderC0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0) rightshoulderC1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0) lefthipC0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0) lefthipC1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0) righthipC0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0) righthipC1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
function Default() neck.C0 = neckC0 neck.C1 = neckC1 rightshoulder.C0 = rightshoulderC0 rightshoulder.C1 = rightshoulderC1 leftshoulder.C0 = leftshoulderC0 leftshoulder.C1 = leftshoulderC1 righthip.C0 = righthipC0 righthip.C1 = righthipC1 lefthip.C0 = lefthipC0 lefthip.C1 = lefthipC1 end
function CreateTag(Attacker, VictimHumanoid) for i, v in pairs(VictimHumanoid:GetChildren()) do if v.Name == "creator" then v:Remove() end end Tag = Instance.new("ObjectValue") Tag.Parent = VictimHumanoid Tag.Name = "creator" Tag.Value = Attacker end
Activated = false
function Attack(mouse)
if not Activated then
Activated = true
local player = game.Players.LocalPlayer if player == nil then return end mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
local pos = mouse.Hit.p
xWalkSpeed = humanoid.WalkSpeed Gyro = Instance.new("BodyGyro") Gyro.Parent = torso Gyro.D = 50 Gyro.maxTorque = Vector3.new(0, 0, 0) Gyro.cframe = torso.CFrame Velocity = Instance.new("BodyVelocity") Velocity.Parent = torso Velocity.maxForce = Vector3.new(0, 0, 0) Position = Instance.new("BodyPosition") Position.Parent = torso Position.maxForce = Vector3.new(0, 0, 0) Velocity.maxForce = Vector3.new(0, 0, 0) humanoid.WalkSpeed = 0 safe = humanoid.Health wait(0.05) |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:14 AM |
part 2 of 2 ___________________________________________________________________________________
Gyro.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
Gyro.cframe = CFrame.new(torso.Position, pos)
torso.CFrame = CFrame.new(torso.Position, pos)
lefthip.C0 = lefthipC0 * CFrame.Angles(-0.5, 0, 0) righthip.C0 = righthipC0 * CFrame.Angles(-0.5, 0, 0) rightshoulder.C0 = rightshoulderC0 * CFrame.Angles(0, 0, 1.57)
FireGrow1 = Instance.new("Part") FireGrow1.Parent = char FireGrow1.Name = "FireGrow" FireGrow1.CanCollide = false FireGrow1.Locked = true FireGrow1.Transparency = 0.6 FireGrow1.TopSurface = "Smooth" FireGrow1.BottomSurface = "Smooth" FireGrow1.formFactor = "Symmetric" FireGrow1.BrickColor = BrickColor.new("White") FireGrow1.CFrame = rightarm.CFrame FireGrow1.Size = Vector3.new(1, 1, 1) Weld = Instance.new("Weld") Weld.Parent = rightarm Weld.Part0 = rightarm Weld.Part1 = FireGrow1 Weld.C0 = CFrame.new(0, -1, 0) Mesh1 = Instance.new("SpecialMesh") Mesh1.Parent = FireGrow1 Mesh1.Scale = Vector3.new(3.25, 3.25, 3.25) Mesh1.MeshType = "Sphere"
FireGrow = Instance.new("Part") FireGrow.Parent = char FireGrow.Name = "FireGrow" FireGrow.CanCollide = false FireGrow.Locked = true FireGrow.Transparency = 0.8 FireGrow.TopSurface = "Smooth" FireGrow.BottomSurface = "Smooth" FireGrow.formFactor = "Symmetric" FireGrow.BrickColor = BrickColor.new("Light blue") FireGrow.CFrame = rightarm.CFrame FireGrow.Size = Vector3.new(1, 1, 1) Weld = Instance.new("Weld") Weld.Parent = rightarm Weld.Part0 = rightarm Weld.Part1 = FireGrow Weld.C0 = CFrame.new(0, -1, 0) Mesh = Instance.new("SpecialMesh") Mesh.Parent = FireGrow Mesh.Scale = Vector3.new(3.75, 3.75, 3.75) Mesh.MeshType = "Sphere"
torso.CFrame = torso.CFrame * CFrame.new(0, 0.1, 0)
for u, c in pairs(workspace:GetChildren()) do if c.Name ~= Me.Name then h = c:findFirstChild("Humanoid") t = c:findFirstChild("Torso") if h ~= nil and t ~= nil then if (torso.Position-t.Position).magnitude <= 15 then Weld = Instance.new("Weld") Weld.Parent = rightarm Weld.Name = "Attach" Weld.Part0 = rightarm Weld.Part1 = t Weld.C0 = CFrame.new(0, -1.5, 1.95) * CFrame.Angles(-1.57, 3.14, 0) torso.Anchored = true wait(0.25) t.Anchored = true Weld:Remove() wait(.001) h.Health = h.Health - 60 end end end end
wait(1)
for i = 1, 50 do humanoid.Health = safe Mesh1.Scale = Mesh1.Scale + Vector3.new(1, 1, 1) Mesh.Scale = Mesh.Scale + Vector3.new(1, 1, 1) for u, c in pairs(workspace:GetChildren()) do if c.Name ~= Me.Name then h = c:findFirstChild("Humanoid") t = c:findFirstChild("Torso") if h ~= nil and t ~= nil then if (torso.Position-t.Position).magnitude <= 50+i then h.Sit = true h.Health = h.Health - 1 t.Velocity = torso.CFrame.lookVector * 190 + Vector3.new(0, 80, 0) if i < 50 then h.Sit = true h.Health = h.Health - 1 CreateTag(Me, h) t.Velocity = torso.CFrame.lookVector * 190 + Vector3.new(0, 80, 0) end if i >= 50 then if h ~= nil and t ~= nil then h.Sit = true t.Anchored = false h.Health = h.Health - 1 t.Velocity = torso.CFrame.lookVector * 190 + Vector3.new(0, 80, 0) end end end end end end wait() end torso.Anchored = false Default() Gyro.maxTorque = Vector3.new(math.huge, math.huge, math.huge) Gyro.cframe = CFrame.new(0, 0, 0) wait() Gyro.maxTorque = Vector3.new(0, 0, 0) Velocity.maxForce = Vector3.new(0, 0, 0) Velocity:Remove() Gyro:Remove() Position:Remove() humanoid.WalkSpeed = xWalkSpeed FireGrow1:Remove() FireGrow:Remove() wait(10) mouse.Icon = "rbxasset://textures\\GunCursor.png" Activated = false end end
function onSelected(mouse) mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() Attack(mouse) end) end
script.Parent.Selected:connect(onSelected)
|
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:21 AM |
| Which key do you want to press to make it work? |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Nov 2015 10:26 AM |
Tool = script.Parent Backpack = Tool.Parent Me = Backpack.Parent PlayerGui = Me.PlayerGui char = Me.Character humanoid = char.Humanoid torso = char.Torso head = char.Head leftarm = char["Left Arm"] rightarm = char["Right Arm"] leftleg = char["Left Leg"] rightleg = char["Right Leg"] neck = torso["Neck"] rightshoulder = torso["Right Shoulder"] leftshoulder = torso["Left Shoulder"] righthip = torso["Right Hip"] lefthip = torso["Left Hip"]
neckC0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0) neckC1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0) leftshoulderC0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0) leftshoulderC1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0) rightshoulderC0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0) rightshoulderC1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0) lefthipC0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0) lefthipC1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0) righthipC0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0) righthipC1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
function Default() neck.C0 = neckC0 neck.C1 = neckC1 rightshoulder.C0 = rightshoulderC0 rightshoulder.C1 = rightshoulderC1 leftshoulder.C0 = leftshoulderC0 leftshoulder.C1 = leftshoulderC1 righthip.C0 = righthipC0 righthip.C1 = righthipC1 lefthip.C0 = lefthipC0 lefthip.C1 = lefthipC1 end
function CreateTag(Attacker, VictimHumanoid) for i, v in pairs(VictimHumanoid:GetChildren()) do if v.Name == "creator" then v:Remove() end end Tag = Instance.new("ObjectValue") Tag.Parent = VictimHumanoid Tag.Name = "creator" Tag.Value = Attacker end
Activated = false
function Attack(mouse, input) if input.KeyCode ~= Enum.KeyCode.Z then print(input.KeyCode) return end if not Activated then
Activated = true
local player = game.Players.LocalPlayer if player == nil then return end mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
local pos = mouse.Hit.p
xWalkSpeed = humanoid.WalkSpeed Gyro = Instance.new("BodyGyro") Gyro.Parent = torso Gyro.D = 50 Gyro.maxTorque = Vector3.new(0, 0, 0) Gyro.cframe = torso.CFrame Velocity = Instance.new("BodyVelocity") Velocity.Parent = torso Velocity.maxForce = Vector3.new(0, 0, 0) Position = Instance.new("BodyPosition") Position.Parent = torso Position.maxForce = Vector3.new(0, 0, 0) Velocity.maxForce = Vector3.new(0, 0, 0) humanoid.WalkSpeed = 0 safe = humanoid.Health wait(0.05) Gyro.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
Gyro.cframe = CFrame.new(torso.Position, pos)
torso.CFrame = CFrame.new(torso.Position, pos)
lefthip.C0 = lefthipC0 * CFrame.Angles(-0.5, 0, 0) righthip.C0 = righthipC0 * CFrame.Angles(-0.5, 0, 0) rightshoulder.C0 = rightshoulderC0 * CFrame.Angles(0, 0, 1.57)
FireGrow1 = Instance.new("Part") FireGrow1.Parent = char FireGrow1.Name = "FireGrow" FireGrow1.CanCollide = false FireGrow1.Locked = true FireGrow1.Transparency = 0.6 FireGrow1.TopSurface = "Smooth" FireGrow1.BottomSurface = "Smooth" FireGrow1.formFactor = "Symmetric" FireGrow1.BrickColor = BrickColor.new("White") FireGrow1.CFrame = rightarm.CFrame FireGrow1.Size = Vector3.new(1, 1, 1) Weld = Instance.new("Weld") Weld.Parent = rightarm Weld.Part0 = rightarm Weld.Part1 = FireGrow1 Weld.C0 = CFrame.new(0, -1, 0) Mesh1 = Instance.new("SpecialMesh") Mesh1.Parent = FireGrow1 Mesh1.Scale = Vector3.new(3.25, 3.25, 3.25) Mesh1.MeshType = "Sphere"
FireGrow = Instance.new("Part") FireGrow.Parent = char FireGrow.Name = "FireGrow" FireGrow.CanCollide = false FireGrow.Locked = true FireGrow.Transparency = 0.8 FireGrow.TopSurface = "Smooth" FireGrow.BottomSurface = "Smooth" FireGrow.formFactor = "Symmetric" FireGrow.BrickColor = BrickColor.new("Light blue") FireGrow.CFrame = rightarm.CFrame FireGrow.Size = Vector3.new(1, 1, 1) Weld = Instance.new("Weld") Weld.Parent = rightarm Weld.Part0 = rightarm Weld.Part1 = FireGrow Weld.C0 = CFrame.new(0, -1, 0) Mesh = Instance.new("SpecialMesh") Mesh.Parent = FireGrow Mesh.Scale = Vector3.new(3.75, 3.75, 3.75) Mesh.MeshType = "Sphere"
torso.CFrame = torso.CFrame * CFrame.new(0, 0.1, 0)
for u, c in pairs(workspace:GetChildren()) do if c.Name ~= Me.Name then h = c:findFirstChild("Humanoid") t = c:findFirstChild("Torso") if h ~= nil and t ~= nil then if (torso.Position-t.Position).magnitude <= 15 then Weld = Instance.new("Weld") Weld.Parent = rightarm Weld.Name = "Attach" Weld.Part0 = rightarm Weld.Part1 = t Weld.C0 = CFrame.new(0, -1.5, 1.95) * CFrame.Angles(-1.57, 3.14, 0) torso.Anchored = true wait(0.25) t.Anchored = true Weld:Remove() wait(.001) h.Health = h.Health - 60 end end end end
wait(1)
for i = 1, 50 do humanoid.Health = safe Mesh1.Scale = Mesh1.Scale + Vector3.new(1, 1, 1) Mesh.Scale = Mesh.Scale + Vector3.new(1, 1, 1) for u, c in pairs(workspace:GetChildren()) do if c.Name ~= Me.Name then h = c:findFirstChild("Humanoid") t = c:findFirstChild("Torso") if h ~= nil and t ~= nil then if (torso.Position-t.Position).magnitude <= 50+i then h.Sit = true h.Health = h.Health - 1 t.Velocity = torso.CFrame.lookVector * 190 + Vector3.new(0, 80, 0) if i < 50 then h.Sit = true h.Health = h.Health - 1 CreateTag(Me, h) t.Velocity = torso.CFrame.lookVector * 190 + Vector3.new(0, 80, 0) end if i >= 50 then if h ~= nil and t ~= nil then h.Sit = true t.Anchored = false h.Health = h.Health - 1 t.Velocity = torso.CFrame.lookVector * 190 + Vector3.new(0, 80, 0) end end end end end end wait() end torso.Anchored = false Default() Gyro.maxTorque = Vector3.new(math.huge, math.huge, math.huge) Gyro.cframe = CFrame.new(0, 0, 0) wait() Gyro.maxTorque = Vector3.new(0, 0, 0) Velocity.maxForce = Vector3.new(0, 0, 0) Velocity:Remove() Gyro:Remove() Position:Remove() humanoid.WalkSpeed = xWalkSpeed FireGrow1:Remove() FireGrow:Remove() wait(10) mouse.Icon = "rbxasset://textures\\GunCursor.png" Activated = false end end
function onSelected(mouse) mouse.Icon = "rbxasset://textures\\GunCursor.png" game:GetService("UserInputService").InputBegan:connect(function(input) Attack(mouse, input) end) end
script.Parent.Selected:connect(onSelected) |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:30 AM |
Thank you so much. The only other problem I have is that not all of my attack scripts look like that. In fact almost every one of them is different, so is there a way that I know where to put this part in them?
function Attack(mouse, input) if input.KeyCode ~= Enum.KeyCode.Z then print(input.KeyCode) return end if not Activated then
Activated = true |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:34 AM |
| If they're all hopperbins, then you need to look for a place where it says ".Selected:connect(X)" and replace the line with "game:GetService("UserInputService"):connect(X)". Then put that input.KeyCode line in it. But this is very very tricky to get right with every script. If you need more help you can just ask us. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:34 AM |
| This also didn't work in a local script :/ |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:35 AM |
| which is what I need it in. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:36 AM |
| I tested it in a local script ;~; |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:36 AM |
| thats weird... Let me try again. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:39 AM |
I may have an easier fix to this. so my problem is that I am making a one piece game, and I need a devil fruit that when you have a certain power, and eat another one. You lose the current power and gain the new one. But I'm having trouble because whenever you have a fruit and you eat another, then you lose both. I also tried another script where You didn't die, but then people get 2 devil fruit powers. I'll post both scripts here if thats ok with you. because if I fix this, I don't need to change every one of them to hotkey. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:42 AM |
This is the one that doesn't kill you, but you keep both powers which I don't want. -----____________________________________________________________________________
wait()
local tool = script.Parent local player = game.Players.LocalPlayer
defaultholdingpos = tool.GripPos eaten = false equipped = false cancelled = false tool.Equipped:connect(function() equipped = true script.Parent.Activated:connect(function() if not eaten then cancelled = false tool.GripPos = Vector3.new(0.8, -0.5, 1.5) tool.Handle.Eat:Play() wait(1.4) tool.Handle.Eat:Stop() if equipped and not cancelled then local currentsavedgear = player:FindFirstChild("StarterGear"):GetChildren() local hasdf = false if #currentsavedgear > 0 then for i = 1, #currentsavedgear do if currentsavedgear[i]:FindFirstChild("DevilFruitAbility") then currentsavedgear[i]:Destroy() hasdf = true end end end if not hasdf then local dftools = script:GetChildren() for i = 1, #dftools do local df_tag = Instance.new("StringValue") df_tag.Name = "DevilFruitAbility" df_tag.Value = tool.DevilFruitType.Value df_tag.Parent = dftools[i] dftools[i]:clone().Parent = player:FindFirstChild("Backpack") dftools[i]:clone().Parent = player:FindFirstChild("StarterGear") end tool:Destroy() elseif hasdf then if player.Character then end end end end end ) end)
tool.Unequipped:connect(function() tool.Handle.Eat:Stop() cancelled = true equipped = false if not eaten then tool.GripPos = defaultholdingpos end end)
|
|
|
| Report Abuse |
|
|
|
| 27 Nov 2015 10:43 AM |
And this is the one that kills you and makes you lose both ______________________________________________________________________
wait()
local tool = script.Parent local player = game.Players.LocalPlayer
defaultholdingpos = tool.GripPos eaten = false equipped = false cancelled = false tool.Equipped:connect(function() equipped = true script.Parent.Activated:connect(function() if not eaten then cancelled = false tool.GripPos = Vector3.new(0.8, -0.5, 1.5) tool.Handle.Eat:Play() wait(1.4) tool.Handle.Eat:Stop() if equipped and not cancelled then local currentsavedgear = player:FindFirstChild("StarterGear"):GetChildren() local hasdf = false if #currentsavedgear > 0 then for i = 1, #currentsavedgear do if currentsavedgear[i]:FindFirstChild("DevilFruitAbility") then currentsavedgear[i]:Destroy() hasdf = true end end end if not hasdf then local dftools = script:GetChildren() for i = 1, #dftools do local df_tag = Instance.new("StringValue") df_tag.Name = "DevilFruitAbility" df_tag.Value = tool.DevilFruitType.Value df_tag.Parent = dftools[i] dftools[i]:clone().Parent = player:FindFirstChild("Backpack") dftools[i]:clone().Parent = player:FindFirstChild("StarterGear") end tool:Destroy() elseif hasdf then if player.Character then if player.Character:FindFirstChild("Humanoid") then player.Character:BreakJoints() player.Character:FindFirstChild("Humanoid").Health = 0 end end tool:Destroy() end end end end) end)
tool.Unequipped:connect(function() tool.Handle.Eat:Stop() cancelled = true equipped = false if not eaten then tool.GripPos = defaultholdingpos end end)
If you can fix this problem for me, I can finally continue making my game. |
|
|
| Report Abuse |
|
|
|
| |
|
|
| |
|
»
»
|
|
|
|
|