Please ignore the error message that says “you must publish to access the DataStore” it from an another script. Just see the first one that is the real error
This is the script by the way:
This script in inside the door part
local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Frame = PlayerGui.LeaderstatsDoorUI.LeaderstatsDoorFrame
local Button = PlayerGui.LeaderstatsDoorFrame.BuyButtonUI
local Button2 = PlayerGui.LeaderstatsDoorFrame.CloseButtonUI
local RequiredCoins = 2000
local debounce = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
Frame.Visible = true
end
end
end)
The second script is this and is inside of:
local leaderstatsDoor = game.Workspace.Door1
local player = game.Players.LocalPlayer
local RequiredCoins = 2000
script.Parent.MouseButton1Click:Connect(function()
if player.leaderstats.Coins.Value >= RequiredCoins then
leaderstatsDoor.Transparency = 1
leaderstatsDoor.CanCollide = false
elseif player.leaderstats.Coins.Value < RequiredCoins then
leaderstatsDoor.Transparency = 0.5
leaderstatsDoor.CanCollide = true
end
end)
From what it looks like, you got an error because you didn’t allow your place to access the DataStoreService (which you can do by publishing your place and switching on the button in the “Security” section of the game’s settings.)
In your first script you have an extra end that you don’t need.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
Frame.Visible = true
end -- closes the if statement
-- end: extra end, you don't need this one
end) -- closes the function used for the touched event
As an aside, indenting your code can help you to know where an `end` needs to be put.
script.Parent.Touched:Connect(function(hit) -- 1 tab for function contents
if hit.Parent:FindFirstChild("Humanoid") then -- 2 tabs if statement contents
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
Frame.Visible = true
end -- end lines up with if clause
end) -- end lines up with function clause
Something I usually do when a script does not work but doesn’t show me any errors, I put a print(“Test”) around every 1-2 lines or so. You could try doing that and see what’s the problem to where the prints stops.
Players.LocalPlayer doesn’t work in normal scripts. Instead you can use this script.
local RequiredCoins = 2000
local debounce = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
local PlayerGui = Player.PlayerGui
local Frame = PlayerGui.LeaderstatsDoorUI.LeaderstatsDoorFrame
local Button = PlayerGui.LeaderstatsDoorFrame.BuyButtonUI
local Button2 = PlayerGui.LeaderstatsDoorFrame.CloseButtonUI
Frame.Visible = true
end
end)