I want to make a gui collision for a gui-based game

so, i want to make a top-down game in roblox made only with gui’s, and i made so the player can move, but how would i make so the player collides the walls?

this is what my gui looks like

i didn’t made any code cuz idk where to start with, but i do have a movement script, and it looks like this

local uis = game:GetService("UserInputService")
local plr = script.Parent.Bg.Plr
local spd = 10
local cd = .3

uis.InputBegan:Connect(function(input, processed)
	if not processed then
		if input.KeyCode == Enum.KeyCode.W then
			repeat
				plr.Position += UDim2.new(0, 0, 0, -spd)
				task.wait(cd)
			until not uis:IsKeyDown(Enum.KeyCode.W)
		end
		if input.KeyCode == Enum.KeyCode.A then
			repeat
				plr.Position += UDim2.new(0, -spd, 0, 0)
				task.wait(cd)
			until not uis:IsKeyDown(Enum.KeyCode.A)
		end
		if input.KeyCode == Enum.KeyCode.S then
			repeat
				plr.Position += UDim2.new(0, 0, 0, spd)
				task.wait(cd)
			until not uis:IsKeyDown(Enum.KeyCode.S)
		end
		if input.KeyCode == Enum.KeyCode.D then
			repeat
				plr.Position += UDim2.new(0, spd, 0, 0)
				task.wait(cd)
			until not uis:IsKeyDown(Enum.KeyCode.D)
		end
	end
end)

This question has been asked before, let me know if you need further help.

it’s because i have a movement system and all, and i don’t just wanna check the collisions, but also make so the player can’t get through a wall

You have to check for collisions every time you move it and cancel/undo the movement when it collides.

makes sense, how didn’t i realized that before? anyway, thanks and have a nice day/night/idk what time is it for you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.