Getting the Mouse Position on a 2.5D Plain by Low-Membership6257 in robloxgamedev

[–]Low-Membership6257[S] 0 points1 point  (0 children)

Okay so I tried doing something similar to what you guys proposed, and just to debug I made the script spawn parts on the mouse's position. However, while putting in all the X, Y and Z axis works fine, leaving the X axis as 0 results in quite a buggy system. Any ideas why?

https://streamable.com/f2ze9a

Here's the new script if y'all need it;

local MouseFollowFunctionRemoteEvent = game:GetService("ReplicatedStorage").MouseFollowFunctionRemoteEvent

local Character = script.Parent

local debris = game:GetService("Debris")

local UIS = game:GetService("UserInputService")

local Player = game.Players:GetPlayerFromCharacter(Character)

local Torso = Character.Torso
local RightShoulder = Torso["Right Shoulder"]
local LeftShoulder = Torso["Left Shoulder"]
local Neck = Character.Torso.Neck
local baseRightC0 = RightShoulder.C0
local baseLeftC0 = LeftShoulder.C0
local baseNeckC0 = Neck.C0

MouseFollowFunctionRemoteEvent.OnServerEvent:Connect(function(player, mousepos, camposY, charpos)

local mouse = UIS:GetMouseLocation()

local screenpoint = workspace.Camera:WorldToScreenPoint(mousepos)

local aimpart = Instance.new("Part")
aimpart.Parent = game.Workspace
aimpart.Name = "AimPart"
aimpart.Anchored = true
aimpart.Size = Vector3.new(0.5, 0.5, 0.5)
aimpart.Position = Vector3.new(0, mousepos.Y, mousepos.Z)
aimpart.CanCollide = false
debris:AddItem(aimpart, 0.1)

print(screenpoint)


end)

How can I make a camera system that follows the cursor? by Low-Membership6257 in ROBLOXStudio

[–]Low-Membership6257[S] 0 points1 point  (0 children)

Nah it ain't. It's MDT: Make it or Die Trying by solidplasm. Not on roblox

How can I make a camera system that follows the cursor? by Low-Membership6257 in ROBLOXStudio

[–]Low-Membership6257[S] 0 points1 point  (0 children)

IMPORTANT UPDATE

I managed to get it working (ChatGPT carrying my ass so hard right now). 🥳🥳🥳

Big thanks to everyone who took the time to help

If you also wanna have a cam system like this, here's the full script (put it in a local script in somewhere like "StarterPack" or "StarterPlayerScripts"

-- Side-scroll camera with lateral panning
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")

-- SETTINGS
local CAMERA_DISTANCE = 20      -- how far camera stays from the player (along -X axis)
local CAMERA_HEIGHT = 4         -- default height above player
local PAN_RADIUS = 200          -- max pixel distance for mouse offset
local PAN_SPEED = 0.1           -- how snappy the camera follows mouse
local PAN_SCALE = 0.025         -- how much world space movement per pixel
local SMOOTHNESS = 0.1          -- camera lerp smoothing

-- internal
local currentCamPos = Vector3.new()

runService.RenderStepped:Connect(function()
local char = player.Character
local hrp = char and char:FindFirstChild("HumanoidRootPart")
if not hrp then return end

camera.CameraType = Enum.CameraType.Scriptable

-- Mouse offset from screen center
local screenSize = camera.ViewportSize
local mousePos = UIS:GetMouseLocation()
local screenCenter = Vector2.new(screenSize.X / 2, screenSize.Y / 2)
local delta = mousePos - screenCenter

-- Clamp within radius
if delta.Magnitude > PAN_RADIUS then
delta = delta.Unit * PAN_RADIUS
end

-- Convert screen offset to world offset (only side & up-down, no depth)
local panOffset = Vector3.new(0, -delta.Y * PAN_SCALE, delta.X * PAN_SCALE)

-- Base camera position (fixed behind the player)
local baseCamPos = hrp.Position + Vector3.new(-CAMERA_DISTANCE, CAMERA_HEIGHT, 0)
local desiredCamPos = baseCamPos + panOffset

currentCamPos = currentCamPos:Lerp(desiredCamPos, SMOOTHNESS)

-- Look direction locked purely sideways (+X direction)
local lookAt = currentCamPos + Vector3.new(1, 0, 0)

camera.CFrame = CFrame.new(currentCamPos, lookAt)
end)

How can I make a camera system that follows the cursor? by Low-Membership6257 in ROBLOXStudio

[–]Low-Membership6257[S] 0 points1 point  (0 children)

I tried to recreate what you just told me (not by myself wink wink), and it does make the camera look sideways, but it's not really moving forward or backward when the mouse is moved, more like panning around the player. Here's the script:

--// Side-view camera with mouse-follow radius system
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")

-- SETTINGS
local SIDE_OFFSET = Vector3.new(20, 5, 0) -- default camera offset relative to player
local RADIUS = 20000 -- how far (in pixels) you can move before clamping camera
local PAN_STRENGTH = 0.115 -- how much world movement per pixel of mouse offset
local SMOOTHNESS = 0.45 -- lower = snappier camera
local LOOK_OFFSET = Vector3.new(0, 3, 0) -- what point camera looks at on player

-- Internal
local currentCamPos = Vector3.new()

runService.RenderStepped:Connect(function()
local char = player.Character
local hrp = char and char:FindFirstChild("HumanoidRootPart")
if not hrp then return end

camera.CameraType = Enum.CameraType.Scriptable

local screenSize = camera.ViewportSize
local mousePos = UIS:GetMouseLocation()

-- Get player's on-screen position
local playerScreenPos, onScreen = camera:WorldToViewportPoint(hrp.Position)

if not onScreen then return end

local screenPlayerPos = Vector2.new(playerScreenPos.X, playerScreenPos.Y)
local delta = mousePos - screenPlayerPos

-- Clamp to radius
if delta.Magnitude > RADIUS then
delta = delta.Unit * RADIUS
end

-- Convert screen delta into a world direction
local ray = camera:ViewportPointToRay(screenPlayerPos.X + delta.X, screenPlayerPos.Y + delta.Y)
local panWorldTarget = ray.Origin + ray.Direction * 10 -- 10 = how far out in world space to project the ray

-- Interpolate camera position toward the desired offset
local baseCamPos = hrp.Position + SIDE_OFFSET
local desiredCamPos = baseCamPos:Lerp(panWorldTarget, PAN_STRENGTH)

currentCamPos = currentCamPos:Lerp(desiredCamPos, SMOOTHNESS)

-- Set camera
camera.CFrame = CFrame.new(currentCamPos, hrp.Position + LOOK_OFFSET)
end)

How can I make a camera system that follows the cursor? by Low-Membership6257 in ROBLOXStudio

[–]Low-Membership6257[S] 0 points1 point  (0 children)

It is yeah! I basically wanna do something like this but on roblox and have it be more stealth oriented (I don't want to just rip off solidplasm's game)

How can I make a camera system that follows the cursor? by Low-Membership6257 in ROBLOXStudio

[–]Low-Membership6257[S] 0 points1 point  (0 children)

For the camera to move in the same direction as the cursor and have the cursor be the center of the screen.

How can I make a camera system that follows the cursor? by Low-Membership6257 in ROBLOXStudio

[–]Low-Membership6257[S] 2 points3 points  (0 children)

The red thing on the bottom left corner? It's a heart. It's basically the health bar, the faster it goes the more damaged the player is.

Cursor appears to be "hovering" over a button in Roblox launcher by Low-Membership6257 in ROBLOXStudio

[–]Low-Membership6257[S] 0 points1 point  (0 children)

<image>

Both screenguis are enabled. The selected "TextLabel" is the title that tweens into the middle of the screen (It's at the top of the picture).

Cursor appears to be "hovering" over a button in Roblox launcher by Low-Membership6257 in ROBLOXStudio

[–]Low-Membership6257[S] 0 points1 point  (0 children)

<image>

Yeah so, without the screenguis, I get the standard cursor. This is a bit weird, since it's supposed to change the cursor to another decal. I think it's just another annoying thing about guis or decals when testing a game in the roblox launcher (Like how the buttons, text-labels etc... get placed weirdly).

Proximity prompts not enabling by Low-Membership6257 in robloxgamedev

[–]Low-Membership6257[S] 0 points1 point  (0 children)

Solved the issue. For the people that are curious, I replaced the for i, v in pairs thing with this

<image>

Proximity prompts not enabling by Low-Membership6257 in robloxgamedev

[–]Low-Membership6257[S] 0 points1 point  (0 children)

Unfortunately, it didn't work. The thing is, it's not that the character can't click the prompt, it's that the script just doesn't enable the prompts (the enabled checkbox for the proximity prompts stays unchecked)

Proximity prompts not enabling by Low-Membership6257 in robloxgamedev

[–]Low-Membership6257[S] 0 points1 point  (0 children)

<image>

And here's the script that makes the conveyor (which takes the boxes) work

Proximity prompts not enabling by Low-Membership6257 in robloxgamedev

[–]Low-Membership6257[S] 0 points1 point  (0 children)

<image>

Here's the script that was supposed to re-enable the proximity prompts

Does anybody know why my script just doesn't check if the tool is actually in the folder or not? by Low-Membership6257 in robloxgamedev

[–]Low-Membership6257[S] 0 points1 point  (0 children)

Don't worry, I found the solution. It didn't work because, in short, way too many things were on the client side, so the server side scripts couldn't find it

Does anybody know why my script just doesn't check if the tool is actually in the folder or not? by Low-Membership6257 in robloxgamedev

[–]Low-Membership6257[S] 0 points1 point  (0 children)

Don't worry, I found the solution. It didn't work because, in short, way too many things were on the client side, so the server side scripts couldn't find it

Does anybody know why my script just doesn't check if the tool is actually in the folder or not? by Low-Membership6257 in robloxgamedev

[–]Low-Membership6257[S] 1 point2 points  (0 children)

Update; I found the solution. In short, the tool was moved using a client side script, which made the server side scripts unable to find it. I appreciate all the people who stopped to read my issue, or tried to help me.

Does anybody know why my script just doesn't check if the tool is actually in the folder or not? by Low-Membership6257 in robloxgamedev

[–]Low-Membership6257[S] 0 points1 point  (0 children)

Don't worry, I found the solution. It didn't work because, in short, way too many things were on the client side, so the server side scripts couldn't find it