Area Door - Remote function is not being invoked!

You can write your topic however you want, but you need to answer these questions:

  1. 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.

  2. 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.

  3. 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!

You don’t need to do the bindable events, etc.

You could just make a simple regular script inside the part that was touched then put the shop gui inside the part, you can then make a touched function and some if statements if a player touched it, you can then clone the gui into the player’s playerguis using local player = hit.Parent:GetPlayerFromCharacter then coding clonedGui.Parent = player.PlayerGui

And after that, you could make a remote event, fire the client of the player then in the local script of the fired client event, it would then remove the area door written on your script.

It’s very simple.

1 Like

Thank you this one really helped me :).

You can mark it a solution if it fixed the problem.

I’ll but I dont want to close it because I didnt test it yet and I dont want to revive discussion but I’ll after I test it :).

Something still doesnt working I think I’m messing it with scripts and local scripts.
Basically everything working but the one local scripts doesnt Invoking server… Btw I need to invoke server because I need to do “Cash.Value = Cash.Value - examplenumber”.

You can fire the server again to change the player’s value, make sure to add an if statement if the player is still in the server or it’ll bug!

So I should use Remote Events instead of using Remote Functions

Yes, they’re easier but more simple, remote functions do the same but with more complexity, so i suggest using remote events for simple stuff.

1 Like

Alright but this isnt thing that is breaking my script yes?

It won’t break if you use remote events right, just be careful when you program one, if you don’t know how to start off with remote events, you could read one about them in developer hub, just google it.

I mean Remote Functions I know what Remote Events do… but I prefer remote functions so thats why I used Remote Functions instead of Remote Events.

Okay, use anything that’ll fix the other problems, good luck.

1 Like

Marked as solution thank you so much dude!

No problem, also do you have further questions?

Not now thank you so much once again! :slight_smile: