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

Why is localscript only working in studio but not game?

Asked by 6 years ago
Edited 6 years ago

Hello, I've scripted a fireball. It works like a charm in roblox studio, however does not work in the actual game. I tried so many things but I don't know how to fix this problem. I would really like to finally know why this is happening and how to fix it. Sorry if my grammar is bad. My game does not have filtered enabled. I would be so happy if someone found a solution to this.

local uis = game:GetService("UserInputService")
local animation = script.Animation
local plr = game.Players.LocalPlayer




function blueball()
    local bball = Instance.new("Part")
    bball.Shape = "Ball"
    bball.CFrame = game.Players.LocalPlayer.Character.Torso.CFrame*CFrame.new(0,0,-5)
    bball.Material = "Neon"
    bball.BrickColor = BrickColor.new("Cyan")
    bball.CanCollide = false
    local BV = Instance.new("BodyVelocity")
    BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    BV.Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector*100
    BV.Parent = bball
    bball.Parent = workspace
    local pe = script.ParticleEmitter:Clone()
    pe.Parent = bball
    bball.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid:TakeDamage(5)
    end
end)
    wait(2)
    bball:Destroy()
end


uis.InputBegan:connect(function(i)
    if i.KeyCode == Enum.KeyCode.F then
            local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Animation)
            anim.KeyframeReached:connect(function(nameofkey)
                if nameofkey == "aylmao" then
                    blueball()
                end
            end)
            anim:Play()
            wait(0.5)
            anim:Stop()
    end
end)

1 answer

Log in to vote
0
Answered by
Eqicness 255 Moderation Voter
6 years ago

Hello, You can use F9 (Fn + F9 on most computers) to open the in-game developers console. I'm guessing you're getting an error about the character's Torso.

This is because only R6 avatars have a "Torso". You can fix this by forcing an avatar type on your Place in the develop tab.

Also, maybe check that your script is definitely a LocalScript, not a Script.

0
Hi, I made sure I used local script. I do have r6 enabled but still doesn’t work. Thanks for the help. activatesenju 2 — 6y
0
Well, did you get any errors? Eqicness 255 — 6y
Ad

Answer this question