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
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
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
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 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.
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.
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