I am trying to make a script to where if you have enough cash and you touch the door or do the proximity promt it pops a gui, if you press yes on that gui it subtracts the cash and opens up the door for only you and nobody else. This is my script I have to open the gui that isnt working so far
local player = game.Players.LocalPlayer
local price = 250
local gui = game.StarterGui.DoorPurchase.Frame
script.Parent.Touched:Connect(function()
if player.leaderstats.Cash.Value < price then
else
gui.Visible = true
end
end)
local ProximityPrompt = script.Parent.ProximityPrompt
ProximityPrompt.Triggered:Connect(function(player)
if player.leaderstats.Cash.Value < price then
else
gui.Visible = true
end
end)
This is a local script inside the door.
Also how would I go about when a player clicks yes it opens the door for only them?
local player = game.Players.LocalPlayer
local price = 250
local gui = game.StarterGui.DoorPurchase.Frame
script.Parent.Touched:Connect(function()
if player.leaderstats.Cash.Value >= price then
gui.Visible = true
-- Then You should here in you're gui make the function that open the door (Always In a local Script)
else
return false
end
end)
local ProximityPrompt = script.Parent.ProximityPrompt
ProximityPrompt.Triggered:Connect(function(player)
if player.leaderstats.Cash.Value >= price then
gui.Visible = true
-- Then You should here in you're gui make the function that open the door (Always In a local Script)
else
return false
end
end)
Nope, My local script is inside of door currently, I got enough cash and everything too no errors either
and the local gui is linked up to the right thing
Then, When the condition is true a Gui Should PopUp gui.Visible = true and inside that gui you should create a local script that if you click “yes” then he removes your money or opens the door (Always on local)
local player = game.Players.LocalPlayer
local price = 250
local gui = game.StarterGui.DoorPurchase.Frame
script.Parent.Touched:Connect(function()
if player.leaderstats.Cash.Value >= price then
gui.Visible = true
-- Then You should here in you're gui make the function that open the door (Always In a local Script)
else
return false
end
end)
local ProximityPrompt = script.Parent.ProximityPrompt
ProximityPrompt.Triggered:Connect(function(player)
if player.leaderstats.Cash.Value >= price then
gui.Visible = true
-- Then You should here in you're gui make the function that open the door (Always In a local Script)
else
return false
end
end)
Where is you’re local Script? You Said that it was inside the door, that mean it will probably be on workspace and Local Script don’t run on Workspace.
I advise not using a local script. Instead, use a Server Script inside your door and when the proximity prompt is triggered, fire a remote event to a local script in the GUI you want to show. When received, activate the GUI. When the buy button is clicked, send another remote event to a server script to complete the transaction!
Um… It kind of works kind of doesnt, I put it in their and stuff and I checked the frame and it was marked visible this time… but um. It wasn’t visible at all. Its weird to explain
local player = game.Players.LocalPlayer
local price = 250
local gui = game.StarterGui.DoorPurchase.Frame
local door = game.Workspace.Maps.Map1.Door
door.Touched:Connect(function()
if player.leaderstats.Cash.Value >= price then
gui.Visible = true
-- Then You should here in you're gui make the function that open the door (Always In a local Script)
else
return false
end
end)
local ProximityPrompt = door.ProximityPrompt
ProximityPrompt.Triggered:Connect(function(player)
if player.leaderstats.Cash.Value >= price then
gui.Visible = true
-- Then You should here in you're gui make the function that open the door (Always In a local Script)
else
return false
end
end)
This is a good solution however the person in this case is not very expert, so to get started using a local script may be fine then over time he will understand how to improve his code
True, but in this case, if he wants to subtract money, he will have to use both local and server scripts to communicate between different instances. Leaderstats transactions cannot be made in a local script.