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

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

1 Like

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.

1 Like

Make sure you are cloning it on the server

1 Like

So… The scripts I use are local scripts
But they use

local Player = game.Players.LocalPlayer
local Character = Player.Character

How do I change that to something that works with global scripts

1 Like

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

1 Like

So you script is inside the paintball ?

Yes
So I can add player damaging

1 Like

Here are both scripts that use LocalPlayer:

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)

How do I make these global?