Trying to fire a paintball

So I have a paintball model located in game.Workspace
I have a script that enables and disables a value (tested and it works)
I want to use that value to determine if the paintball gun should start firing
Here is what I made:

local Player = game.Players.LocalPlayer
local Character = Player.Character
local FiringPoint = Character:WaitForChild("FiringPoint")
local ink = game.Workspace.Ink

while script.Parent.active.Value == true do
	print("Attempting to fire")	
	local paint = ink:Clone()
	paint.Parent = game.Workspace
	paint.Anchored = false
	paint.Position = FiringPoint.CFrame.Position
	wait(0.2)
end

What should I change? It doesn’t even trigger when I try to fire

The loop doesn’t even initiate

Is this the whole script? Try

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local FiringPoint = Character:WaitForChild("FiringPoint")
local ink = workspace.Ink

while true do
	if script.Parent.active.Value == true then
		print("Attempting to fire")	
		local paint = ink:Clone()
		paint.Parent = game.Workspace
		paint.Anchored = false
		paint.Position = FiringPoint.CFrame.Position
		wait(0.2)
	end
end

Nope
I don’t even know what’s wrong cause it isn’t giving any errors or warnings

Is the script Disabled or is it in any container that won’t run it?

It is in StarterGUI and is enabled
Should I use a localscript or a normal script?
I know the loop isn’t starting because the print function isn’t starting
I tested the other script and it is working perfectly

Depends if you want to make it visible to others or not.

What other script?

The script setting active to true or false
I can literally go into PlayerGUI while running and the value is in fact changing

Try this loop:

while true do
	if script.Parent.active.Value == true then
		print("Attempting to fire")	
		local paint = ink:Clone()
		paint.Parent = game.Workspace
		paint.Anchored = false
		paint.Position = FiringPoint.CFrame.Position
		task.wait(0.2)
	else
		task.wait(0.2)
	end
end

Not even an output
Just the other script telling me that it succesfully changed the value

Not sure why it wouldn’t work beneath another loop stopping the script or something being configuring the script in some way.
From what I learned from debugging, try putting a print before the loop and check if that prints.

Ok so it spontaniously started working
Thanks

1 Like

And… the paintball’s script broke
Gonna make another topic

If its a Script then it won’t execute in the PlayerGui, which is where it gets cloned from StarterGui when someone joins.

If you want to make a proper gun system then implement it with Multiplayer perspective in mind, since if you just fire on the local player, others won’t see it.

There are some really great Guns / FPS Framework resources on the Developer forum, which you should be able to utilize.

The paintball is moved to the Workspace

And the paintball is supposed to have physics while normal gun scripts dont account for physics or anything
Ima stick to doing it using my own stuff

Anyway new thread How do I change my scripts to global? (Not Solved)

I am not asking you to copy any resources, you can have your own coding style, your own system - but open source resources on those will help you to understand how a standard framework might work.

Anyway I do not need anything special
All I need is that:
The paintball fires
The paintball gets launched a bit (gonna try that myself soon)
The paintball changes into the splash model when it lands

Thats all I need for the shooting part