Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help With Context Action Service?

Asked by
yoshiegg6 176
9 years ago

Can anyone help me with this? It's supposed to be in a local script in a tool. When the player presses r it does the actual function of cloning a model and playing an animation.

--Normal variable setup
local player = game.Players.LocalPlayer
local char = player.Character
local debounce = false
local stamina = 20

--Setting up the animation 
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=?????????"
local animTrack = player.Humanoid:LoadAnimation(animation)
--Context Action Service
local CAS = game:GetService("ContextActionService")

--Actual function I want to happen
function firewall()
if debounce or stamina <= 7 then return end
stamina - 7
local CF = game.ServerStorage.Wall:Clone()
CF.Parent = script.Parent
CF.MainPart.Position = char.Torso.Position + Vector3.new(5,0,0)
CF.MainPart.Rotation = char.Torso.Rotation
animTrack:Play()
debounce = true
wait(5)
debounce = false
end


script.Parent.Equipped:connect(function()
CAS:BindActionToInputTypes("wall", firewall, false, "r")
end 
end)

script.Parent.UnEquippedd:connect(function()
CAS:UnbindAction("wall")
end
end)

Thanks

Answer this question