Also this is in a local script in starter player scripts (I'm not attempting to make this replicated for all clients as ill be making it a 1 player game.). The issue: The portals are spawning approximately -340282346638528859811704183484516925440 studs away from the position where they are suppost to be (on Y axis, never changes, also x and z are always 0.) Here is my script:

--Portal
local PortalPart = Instance.new("Part")
PortalPart.FormFactor = "Custom"
PortalPart.Size = Vector3.new(1, 1, 0.2)
PortalPart.Anchored = true
PortalPart.CanCollide = false
PortalPart.Transparency = 1
--Portal Instances
BluePortal = nil
OrangePortal = nil
--Services
UserInputService = game:GetService("UserInputService")
PlayerMouse = game:GetService("Players").LocalPlayer:GetMouse()
--Portal Creation
function CreatePortal(PortalType)
	local ray = Ray.new(game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.Position, (game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.Position - PlayerMouse.Hit.p).Unit)
	local hit, pos, normal = game.Workspace:FindPartOnRay(ray)
	if PortalType == "Orange" then
		local Decal = "rbxassetid://4700310731"
		OrangePortal = PortalPart:Clone()
		OrangePortal.Name = "Orange Portal"
		OrangePortal.Parent = game.Workspace.Portals
		OrangePortal.CFrame = CFrame.new(pos, pos + normal)
		local PortalPartDecal = Instance.new("Decal", OrangePortal)
		PortalPartDecal.Face = "Front"
		PortalPartDecal.Texture = Decal
	end
	if PortalType == "Blue" then
		local Decal = "rbxassetid://4700309101"
		BluePortal = PortalPart:Clone()
		BluePortal.Name = "Blue Portal"
		BluePortal.Parent = game.Workspace.Portals
		BluePortal.CFrame = CFrame.new(pos, pos + normal)
		local PortalPartDecal = Instance.new("Decal", BluePortal)
		PortalPartDecal.Face = "Front"
		PortalPartDecal.Texture = Decal
	end
end
--Portal Detection
UserInputService.InputBegan:Connect(function(key)
	local PortalType = "None"
	if key.KeyCode == Enum.KeyCode.Q then
		PortalType = "Blue"
	end
	if key.KeyCode == Enum.KeyCode.E then
		PortalType = "Orange"
	end
	if PortalType ~= "None" then
		local MouseTarget = PlayerMouse.Target
		if PortalType == "Blue" then
			if MouseTarget ~= BluePortal then
				if BluePortal ~= nil then
					BluePortal:Destroy()
				end
				CreatePortal("Blue")
			end
		elseif PortalType == "Orange" then
			if MouseTarget ~= OrangePortal then
				if OrangePortal ~= nil then
					OrangePortal:Destroy()
				end
				CreatePortal("Orange")
			end
		end
	end
end)

Everything else seems to be working fine currently though

1 comment

0

also no errors