I made this shop system, and whenever people step into the shop area it a gui pops up, so the problem is people abuse this system and have the shop gui pop up then just walk out of the shop and then buy the item
I tried making it so when the player enters the shop it removes their walkspeed and jump but im really not sure how to add it.
Any help would be awesome, since im not very good at lua
Here the lua (The lua makes the GUI pop up)
local debounce = false
local remote = game:GetService("ReplicatedStorage").ShopRemotes.OpenShop
script.Parent.Touched:Connect(function(hit)
if debounce then return end
debounce = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
remote:FireClient(player)
end
wait(3)
debounce = false
end)
local debounce = false
local remote = game:GetService("ReplicatedStorage").ShopRemotes.OpenShop
script.Parent.Touched:Connect(function(hit)
if debounce then return end
debounce = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local character = player.Character
if character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
remote:FireClient(player)
task.delay(3, function()
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
end)
end
end
end
task.wait(3)
debounce = false
end)
How long should they not be able to move for? Currently the time is set to 3 seconds, feel free to alter that by changing the first argument to task.delay().
You can try just making the shop screen full screen so then they can’t see where they’re going, and would stop walking out of the shop with it open. Alternatively you can detect keyboard inputs and have the UI automatically close when they are detected (to detect attempts to move).
So I suppose your script is a Server Script and you want players to stop moving when they step in a certain part right? I saw you made something like
remote:FireClient(player)
So a local script will receive the remote event’s signal and do its function like pop up gui. I suggest you can disable the player’s movement along with the other functions
You can do this:
local LocalPlr = game:GetService("Players").LocalPlayer
local PlrControl = require(LocalPlr.PlayerScripts.PlayerModule):GetControls()
PlrControl:Disable()
Therefore, the player can’t move while stepping in the part.
When the player press a “X” button in the Shop Ui, then Enable it’s control and disable the Gui.
Thats where my problem comes in, i dont know how to connect it to the exit button for the shop GUI. heres the close shop button for the gui if it helps
You should just do script.Parent.TouchEnded:Connect(function() and close the GUI when that event gets fired.
If the GUI starts to get glitchly like constantly opening and closing, extend the hitbox for detecting if the player touched it to be taller than the player and only check if the HumanoidRootPart touched it.
HumanoidRootPart because it doesn’t move when animations play and is always in the center of the player.
I have a question. How do you do TouchEnded when you can’t move? Since I think @NavenTheNoob doesn’t want the players to move when the Shop Gui Pops Up.
So i saw that most people like go to the shop, get the gui on their screen. then walk somewhere else and buy the item. I need people to stay in the shop building. Also the GUI is half transparent so they would still see where their going.