I have a local script that gets the position of the player head and turns it into a variable called "PlayerXYZ".

name = game.Players.LocalPlayer.Name

while true do
	_G.PlayerXYZ = game.Workspace[name].Head.Position
	wait(0.01)
end 

This variable needs to be used in this script for spawning a part, but I can't figure out how to make the variable global so it can be used in this script.

function spawnPart()
	local createdPart = originalPart:Clone()
	createdPart.Parent = workspace
	createdPart.Position = Vector3.new(_G.PlayerXYZ)
	print("Anchor Block Spawned!")
end

Is there any way to do this?

1 comment

0

Pretty sure you can only communicate from local script to global script with remote events. Globals are used to communicate server to server scripts.