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

ContextActionsService issue when trying to play script? SOLVED With the help of brokenVectors [closed]

Asked by 4 years ago
Edited 4 years ago

This has already been solved, button shows up now

0
Dude, please just put your script in code lines. I don't wanna use pastebin lol Cynical_Innovation 595 — 4y
0
k here check my answer JeffTheEpicRobloxian 258 — 4y

Closed as Non-Descriptive by botw_legend, iivSnooxy, IAmNotTheReal_MePipe, Dovydas1118, and Leamir

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

3 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

There are a lot of issues with your code.

  1. Almost 70% of all your lines are just creating trails and editing their properties. You can make an array of all the player's limbs, and parent the trails to them.

  2. You're connecting the function inside of the function, which makes absolutely no sense and it doesn't work.

  3. You also have an event inside of the function that's connected, which also makes no sense??? This will cause memory leaks and it's just useless.

  4. :remove() is deprecated. Use :Destroy() instead.

  5. You're defining the player twice.

  6. You're redefining the character???

  7. CharacterAdded isn't written correctly, thanks @Dovydas118 for noticing lol

  8. You're using the second parameter of Instance.new, which parents the object even before you change any properties, which then fires all the Changed events(decreases performance a ton)

Note that I didn't fix every single issue, I'll leave that up to u. Please tell me if anything doesn't work.

local player = game.Players.LocalPlayer

local Char = player.Character or player.CharacterAdded:Wait()
local UIS = game:GetService("UserInputService")
local humanoid = player.Character:WaitForChild("Humanoid")
local context = game:GetService("ContextActionService")

local debounce = false
local cooldown = 1 -- Time to wait between 2 dash

local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=5311749838"--Insert ID here
local function Onbuttonpress()


        if debounce == false then
            debounce = true
            local playAnim = humanoid:LoadAnimation(anim)
            playAnim:Play()
            local Character = game.Workspace:WaitForChild(player.Name)
            Char.HumanoidRootPart.Velocity = Char.HumanoidRootPart.CFrame.lookVector*500
            local Trail1 = Instance.new("Trail",Character)
            Trail1.Attachment0 = Character.RightFoot:FindFirstChildOfClass("Attachment")
            Trail1.Attachment1 = Character.RightLowerLeg:FindFirstChildOfClass("Attachment")
            Trail1.Lifetime = 0.2
            Trail1.MaxLength = 1
            Trail1.WidthScale = NumberSequence.new(0.8)
            Trail1.FaceCamera = false
            local Trail2 = Instance.new("Trail",Character)
            Trail2.Attachment0 = Character.LeftFoot:FindFirstChildOfClass("Attachment")
            Trail2.Attachment1 = Character.LeftLowerLeg:FindFirstChildOfClass("Attachment")
            Trail2.Lifetime = 0.2
            Trail2.MaxLength = 0.5
            Trail2.WidthScale = NumberSequence.new(0.8)
            Trail2.FaceCamera = false
            local Trail3 = Instance.new("Trail",Character)
            Trail3.Attachment0 = Character.LeftLowerArm:FindFirstChildOfClass("Attachment")
            Trail3.Attachment1 = Character.LeftHand:FindFirstChildOfClass("Attachment")
            Trail3.Lifetime = 0.2
            Trail3.MaxLength = 0.5
            Trail3.WidthScale = NumberSequence.new(0.8)
            Trail3.FaceCamera = false
            local Trail4 = Instance.new("Trail",Character)
            Trail4.Attachment0 = Character.RightLowerArm:FindFirstChildOfClass("Attachment")
            Trail4.Attachment1 = Character.RightHand:FindFirstChildOfClass("Attachment")
            Trail4.Lifetime = 0.25
            Trail4.MaxLength = 0.5
            Trail4.WidthScale = NumberSequence.new(0.8)
            Trail4.FaceCamera = false
            local Trail5 = Instance.new("Trail",Character)
            Trail5.Attachment0 = Character.UpperTorso:FindFirstChildOfClass("Attachment")
            Trail5.Attachment1 = Character.LowerTorso:FindFirstChildOfClass("Attachment")
            Trail5.Lifetime = 0.25
            Trail5.MaxLength = 0.5
            Trail5.WidthScale = NumberSequence.new(0.8)
            Trail5.FaceCamera = false
            wait(.5)
            for i = 0,1, .1 do
                Trail1.Transparency = NumberSequence.new(i)
                Trail2.Transparency = NumberSequence.new(i)
                Trail3.Transparency = NumberSequence.new(i)
                Trail4.Transparency = NumberSequence.new(i)
                Trail5.Transparency = NumberSequence.new(i)
                wait()
            end
            Trail1:Destroy()
            Trail2:Destroy()
            Trail3:Destroy()
            Trail4:Destroy()
            Trail5:Destroy()
            wait(cooldown)
            debounce = false
        end


    end
    end)
    end
context:BindAction("Startdash", Onbuttonpress, true, "q")
context:SetTitle("Startdash", "Dash")
context:SetPosition("Onbuttonpress", UDim2.new(0.628, 0,0.767, 0))

Hope this helped

Ad
Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

I am not sure... But don't you have to put the end on the same imaginary horizontal line? Or is that for easy reference? Please don't criticise me for my opinion...

0
I have no idea JeffTheEpicRobloxian 258 — 4y
0
This should be a comment instead of an answer because it doesn't answer the question... brokenVectors 525 — 4y
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local player = game.Players.LocalPlayer

local Char = player.Character or player.CharacterAdded:Wait()
local UIS = game:GetService("UserInputService")
local humanoid = player.Character:WaitForChild("Humanoid")
local context = game:GetService("ContextActionService")

local debounce = false
local cooldown = 1 -- Time to wait between 2 dash

local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=5311749838"--Insert ID here
local function Onbuttonpress()


        if debounce == false then
            debounce = true
            local playAnim = humanoid:LoadAnimation(anim)
            playAnim:Play()
            local Character = game.Workspace:WaitForChild(player.Name)
            Char.HumanoidRootPart.Velocity = Char.HumanoidRootPart.CFrame.lookVector*500
            local Trail1 = Instance.new("Trail",Character)
            Trail1.Attachment0 = Character.RightFoot:FindFirstChildOfClass("Attachment")
            Trail1.Attachment1 = Character.RightLowerLeg:FindFirstChildOfClass("Attachment")
            Trail1.Lifetime = 0.2
            Trail1.MaxLength = 1
            Trail1.WidthScale = NumberSequence.new(0.8)
            Trail1.FaceCamera = false
            local Trail2 = Instance.new("Trail",Character)
            Trail2.Attachment0 = Character.LeftFoot:FindFirstChildOfClass("Attachment")
            Trail2.Attachment1 = Character.LeftLowerLeg:FindFirstChildOfClass("Attachment")
            Trail2.Lifetime = 0.2
            Trail2.MaxLength = 0.5
            Trail2.WidthScale = NumberSequence.new(0.8)
            Trail2.FaceCamera = false
            local Trail3 = Instance.new("Trail",Character)
            Trail3.Attachment0 = Character.LeftLowerArm:FindFirstChildOfClass("Attachment")
            Trail3.Attachment1 = Character.LeftHand:FindFirstChildOfClass("Attachment")
            Trail3.Lifetime = 0.2
            Trail3.MaxLength = 0.5
            Trail3.WidthScale = NumberSequence.new(0.8)
            Trail3.FaceCamera = false
            local Trail4 = Instance.new("Trail",Character)
            Trail4.Attachment0 = Character.RightLowerArm:FindFirstChildOfClass("Attachment")
            Trail4.Attachment1 = Character.RightHand:FindFirstChildOfClass("Attachment")
            Trail4.Lifetime = 0.25
            Trail4.MaxLength = 0.5
            Trail4.WidthScale = NumberSequence.new(0.8)
            Trail4.FaceCamera = false
            local Trail5 = Instance.new("Trail",Character)
            Trail5.Attachment0 = Character.UpperTorso:FindFirstChildOfClass("Attachment")
            Trail5.Attachment1 = Character.LowerTorso:FindFirstChildOfClass("Attachment")
            Trail5.Lifetime = 0.25
            Trail5.MaxLength = 0.5
            Trail5.WidthScale = NumberSequence.new(0.8)
            Trail5.FaceCamera = false
            wait(.5)
            for i = 0,1, .1 do
                Trail1.Transparency = NumberSequence.new(i)
                Trail2.Transparency = NumberSequence.new(i)
                Trail3.Transparency = NumberSequence.new(i)
                Trail4.Transparency = NumberSequence.new(i)
                Trail5.Transparency = NumberSequence.new(i)
                wait()
            end
            Trail1:Destroy()
            Trail2:Destroy()
            Trail3:Destroy()
            Trail4:Destroy()
            Trail5:Destroy()
            wait(cooldown)
            debounce = false

    end
    end
context:BindAction("Startdash", Onbuttonpress, true, "q")
context:SetTitle("Startdash", "Dash")
context:SetPosition("Onbuttonpress", UDim2.new(0.628, 0,0.767, 0))

0
This above creats trails and dashes the player in the direction the player is facing JeffTheEpicRobloxian 258 — 4y