Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is localscript only working in studio but not game?

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

✓ Accepted answer

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.

2 comments

0

Hi, I made sure I used local script. I do have r6 enabled but still doesn’t work. Thanks for the help.

0

Well, did you get any errors?

This discussion is preserved as it was. New answers, comments, and votes are closed.