Bug with my zone door script!

it only prints these two Hi’s

image

1 Like

Make sure to give yourself enough coins.

1 Like

um i had 2.5k coins so i dont knwo why it didnt work

Is there any related error(s)? And does the leaderstats exist in the player?

1 Like

leaderstats do exist in player

Please screenshot the entire leaderstats.


image

Now when i touch it only prints this Hi
image

Open the leaderstats folder and screenshot its children.

image

Does the remote event exist in ReplicatedStorage?

1 Like

YEs it does image

Try using game:GetService(“ReplicatedStorage”). Events:WaitForChild(“Buy”)

1 Like

its just prints this

Make each print() outputs different results.

And add a few seconds of delay at the start of the script.

Ok here you go buddy

1 Like

I recommend just making a DataStore for what doors the player owns, and then the player auto-invokes server on join, and the server returns if the player owns it or not, if they do, it destroys the door, if they don’t, it keeps the door. To make better protection, have a big part in each zone ( area you enter after the door ) , every time it is touched, it checks if the player owns the door to that zone, if they don’t, and exploited to get there, then make their Health 0.

1 Like

yea ik about that,but it wotn let me purchase the zone

Are there any errors currently that are displayed? Remove all the print statements, so the errors are more clear ( if any ). Before debugging, we look for errors.

1 Like
local Buy = game:GetService("ReplicatedStorage").Events:WaitForChild("Buy")
local db = false
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
          local player = game.Players:GetPlayerFromCharacter(hit.Parent)
         if db == false then
            db = true
			if player.leaderstats.Coins.Value >= 1250 then
				 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 1250
				Buy:FireClient(player)
			 wait(.2)
            db = false
			end
        end
    end
end)

Heres the local script for the Buy Events

local yourRemote = game.ReplicatedStorage.Events.Buy
yourRemote.OnClientEvent:Connect(function()	
local Player = game.Players.LocalPlayer
       game.Workspace.Snow:Destroy()
	
end)

local yourRemote2 = game.ReplicatedStorage.Events.Buy2
yourRemote2.OnClientEvent:Connect(function()
	local Player = game.Players.LocalPlayer
		game.Workspace.DesertDoor:Destroy()
end)


local yourRemote3 = game.ReplicatedStorage.Events.Buy3
yourRemote3.OnClientEvent:Connect(function()
	local Player = game.Players.LocalPlayer
		game.Workspace.Snow1:Destroy()
end)