I’m struggling to make a script for my game, its a bit like a tycoon but i need a script where when you step on a part if you have enough money then it will make a part visible, here is the script i have so far:
local player = game:GetService(“Players”).LocalPlayer
local part = workspace.BuyStages.ObbyPart1
local cash = player:WaitForChild(“leaderstats”):WaitForChild(“Cash”)
local Stage1 = game.Workspace[“Stage 1”]
while true do
part.Touched:Connect(function(hit)
if hit.Parent == player.Character then
if cash >= 100 then
Stage1.Visible = true
Stage1.CanColide = true
end
end
end)
end
btw the indentations didnt show when i pasted the script, i have already added them in the real script though so dont worry about indentations and stuff
local player = game:GetService("Players").LocalPlayer
local part = workspace.BuyStages.ObbyPart1
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
local Stage1 = game.Workspace:WaitForChild("Stage1")
part.Touched:Connect(function(hit)
if hit.Parent == player.Character or player.CharacterAdded:wait() then
if cash.Value >= 100 then
Stage1.Transparency= 0
Stage1.CanColide = true
end
end
end)
local player = game:GetService(“Players”).LocalPlayer
local part = workspace.BuyStages.ObbyPart1
local cash = player:WaitForChild(“leaderstats”):WaitForChild(“Cash”)
local Stage1 = game.Workspace[“Stage 1”]
part.Touched:Connect(function(hit)
if hit.Parent == player.Character or player.CharacterAdded:wait() then
if cash.Value >= 100 then
Stage1.Transparency = 0
Stage1.CanColide = true
end
end
end)
what script u using? localplayer (firstline) only works on a local script on the client
replace ur current code with this:
local part = workspace.BuyStages.ObbyPart1
local Stage1 = game.Workspace[“Stage 1”]
part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player then return end
local cash = player:WaitForChild(“leaderstats”):WaitForChild(“Cash”)
if hit.Parent == player.Character then
if cash.Value >= 100 then
if Stage1:IsA("BasePart") then
Stage1.Transparency = 0
Stage1.CanColide = true
else
for _,p in ipairs(Stage1:GetDescendants()) do
if not p:IsA("BasePart") then continue end
p.Transparency = 0
p.CanColide = true
task.wait()
end
end
end
end
end)
local player = game:GetService(“Players”).LocalPlayer
local part = workspace.BuyStages.ObbyPart1
local cash = player:WaitForChild(“leaderstats”):WaitForChild(“Cash”)
local Stage1 = game.Workspace[“Stage 1”]
part.Touched:Connect(function(hit)
if hit.Parent == player.Character then
if cash >= 100 then
Stage1.Visible = true
Stage1.CanColide = true
end
end
end)
Try this, is it server sided also? If it is not try using physics service for the cancollide and visible stuff. The client should not change workspace properties because roblox thinks that’s hacking, switch it to a server script and when it’s clicked set the physic owner idk what it’s called to the player and fire a remote event to request the client to then cancollide it