You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
I’m making my Area Door so basically you come close to the “Area Door” and then Frame from StarterGui pops up and you should be able to buy. -
What is the issue? Include screenshots / videos if possible!
When I tried to click buy button it it sometimes invoke the remotefunction and sometimes not and I dont really know what’s wrong. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Printing and I tried to do some research.
Normal script inside Area Door that is opening Frame from StarterGui:
local Door = script.Parent
Door.Touched:Connect(function(Object)
if Object.Parent:IsA("Model") and (Object.Parent:FindFirstChild("Humanoid") ~= nil) then
local Player = Object.Parent.Name
local plr = game.Players:FindFirstChild(Player)
game.ReplicatedStorage.DoorFolder.DoorO1:InvokeClient(plr)
Event:FireClient(game.Players[Player], Door.Name, Door)
end
end)
Local script inside StarterGui that pop ups Frame:
local Frame = script.Parent.Parent.Parent.Parent.Parent.DoorFrame1
game.ReplicatedStorage.DoorFolder.DoorO1.OnClientInvoke = function()
if Frame.Position == (UDim2.new(0.5, 0, 2, 0)) then
print("yes")
Frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quad")
return true
end
return false
end
Local script inside StarterGui that is handling RemoteFunction when Buy Button being bought
script.Parent.MouseButton1Click:Connect(function()
print("x")
game.ReplicatedStorage.DoorFolder.DoorF1:InvokeServer()
print("Invoked")
end)
Normal Script inside ServerScriptServices that is listening if Buy Button is being invoked:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local req1 = 10000 --Need to change
function DoorF1(player)
local Opened1 = player.Bool:FindFirstChild("Opened1")
local Cash = player.leaderstats:FindFirstChild("Cash")
if Cash.Value >= req1 then
Cash.Value = Cash.Value - req1
print("true")
Opened1.Value = true
return true
end
return false
end
game.ReplicatedStorage.DoorFolder.DoorF1.OnServerInvoke = DoorF1
Normal Script inside ServerScriptServices that is checking if Opened value == true:
local player = game.Players.LocalPlayer
local Event = game.ReplicatedStorage.OpenDoor
local Door = game.Workspace.Door1
local function addDoor(player)
while wait(3) do
if player.Bool.Opened1.Value == true then
Event:FireClient(player, Door.Name, Door)
end
end
end
game.Players.PlayerAdded:Connect(addDoor)
And last Local Script inside StarterPlayerScripts that is removing Area Door:
local Event = game.ReplicatedStorage.OpenDoor
local Required = require(game.ReplicatedStorage.Required1)
local Player = game.Players.LocalPlayer
Event.OnClientEvent:Connect(function(Door1, Door)
if Player.Bool.Opened1.Value == Required[Door1].Opened1 then
Door.CanCollide = false
wait(.5)
Door.CanCollide = true
Door:Destroy()
end
end)
Thank you for any help! I know it might be confusing but I done almost everything by myself!