This might not make sense, but i've made a LocalScript that basically makes an ImageLabel controllable by the player. (Using WASD) What I need is a script that makes a Frame (ImageLabel, etc.) impossible to pass through. For example, you cannot go past the left side of the screen in Super Mario Bros. Here is the code:
wait(0.1) local runservice = game:GetService("RunService") local position2 = game.Players.LocalPlayer.PlayerGui.ScreenGui.ImageLabel runservice.RenderStepped:connect(function() if script.Up.Value == true then position2.Left.Disabled = true position2.Right.Disabled = true position2.Down.Disabled = true position2.Up.Disabled = false position2.Position = position2.Position + UDim2.new(0,0,-0.0025,0) end if script.Down.Value == true then position2.Left.Disabled = true position2.Right.Disabled = true position2.Down.Disabled = false position2.Up.Disabled = true position2.Position = position2.Position + UDim2.new(0,0,0.0025,0) end if script.Right.Value == true then position2.Left.Disabled = true position2.Right.Disabled = false position2.Down.Disabled = true position2.Up.Disabled = true position2.Position = position2.Position + UDim2.new(0.0025,0,0,0) end if script.Left.Value == true then position2.Left.Disabled = false position2.Right.Disabled = true position2.Down.Disabled = true position2.Up.Disabled = true position2.Position = position2.Position + UDim2.new(-0.0025,0,0,0) end end)
Here is the game if more info is needed: https://www.roblox.com/games/3481420494/frisk-moving-test
I see what you're attempting to do. I've tried something similar to this myself a while back. Essentially, before the actual movement you need to check that you won't surpass a certain point. This is a quickly whipped up example that should suffice for what you're trying to do using your left as an example:
if script.Left.Value == true and (position2.Position.X.Scale - .0025) > 0 then position2.Left.Disabled = false position2.Right.Disabled = true position2.Down.Disabled = true position2.Up.Disabled = true position2.Position = position2.Position + UDim2.new(-0.0025,0,0,0) end
In the case of trickier values such as down:
if script.Down.Value == true and (position2.Position.Y.Scale + .0025) < ((frame's size) - (the image label's X scale size)) --rest of your down code here
So in the case of down and right which don't end on 0, you'll want what the frame's size is and subtract the size of the frame that it's in by your imagelabel's scale so that it can never surpass the edge of your right side + imagelabel's size.
Kinda hard for me to properly explain without showing a direct demonstration but I hope you understand and that this helps solve your issue.
This makes no sense. If a frame is on a surface gui which is on a part, then simply change the CanCollide value in the part to true, problem solved.
It seems like no one knows or how to script this. I might delete this soon.
You can make an if script that won't let you move if you pass a certain position.