So I tried making my script so that when u click, tap, etc it will launch a fireball but this only works on roblox studio and not online. Idk why. THIS IS IN A SCRIPT. Pls Help! <3
My code
local tool = script.Parent local handle = tool:WaitForChild("Handle") local player = game.Players.LocalPlayer local char = player.Character or player.CharacterAdded:Wait() local head = char:WaitForChild("Head") local ammo = 1 tool.Activated:Connect(function() if ammo == 1 then ammo = 0 local fireballclone = game.ServerStorage.BallEx:Clone() fireballclone.Parent = game.Workspace fireballclone.Position = head.Position + (head.CFrame.lookVector * 8) local v = Instance.new("BodyVelocity") v.MaxForce = Vector3.new(math.huge, math.huge, math.huge) v.Velocity = player.Character.UpperTorso.CFrame.lookVector * 80 v.Parent = fireballclone wait(3) ammo = 1 end end)
The script used is a local script. If the game is filtering enabled, then the local script would not be able to access server-sided services such as ServerStorage
.
Use ReplicatedStorage
instead.
So if this is in a script, then you can't use LocalPlayer
.
This is a common mistake and its usually easily fixable.
What you could do is put the script inside the tool and use .Parent
to find the player.
This should work:
player = script.Parent.Parent.Parent
You will more than likely need to set Disabled = false
if your moving the script or have it detect when its parent changes using:
script.Parent.AncestryChanged:Connect(function(c,p) --do stuff end)