referring to this
I have a paintball that when it hits the baseplate (not anything else yet) it deletes itself and clones an object called “splash” at its location (except for y)
The original works fine but when I clone it with the script mentioned above it suddenly doesnt work
Here is the script:
function onTouched(part)
local original = game.Workspace.Splash
local copy = original:Clone()
print("Touched part")
while true do
print("Loop running")
if part.Name == "Baseplate" then
print("Touched floor")
copy.Parent = game.Workspace
copy.Position = Vector3.new(script.Parent.Position.X, 0.001, script.Parent.Position.Z)
script.Parent:Destroy()
end
end
end
script.Parent.Touched:connect(onTouched)
It doesn’t output anything from any prints unless its the original
Try removing this as touched events fire as soon as it touches and it waits for the signal so there is no need to check is constantly. If you still want to use it, use RunService or while wait() do
It will print and copy and infinite amount of copies and break your script because the part name will always be baseplate because it’s what it last touched.
EDIT: There is also no need for if part.Name == 'Baseplate' because the script is in the baseplate itself.
No it is in the paintball
The paintball checks if the part it hit was the baseplate so it knows if it should splash or not
It is done like this so I can add player damage later
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
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
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
local FiringPoint = Character:WaitForChild("FiringPoint")
local ink = game.Workspace.Ink
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.B then
script.Parent.active.Value = true
print("Active")
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.B then
script.Parent.active.Value = false
print("No longer active")
end
end)