Sorry if my english isn’t very clear.
-
What do you want to achieve? Keep it simple and clear!
I want to create a tycoon system where you can get your tycoon only by touching the door. -
What is the issue? Include screenshots / videos if possible!
I can’t get the Player, when I made a simpler script to claim the tycoon its worked but the player could get all the tycoons, so with another script I added a Bollean Value that starts with false and gets true when the player claim a tycoon, the problem is the game give the error “Index nil with Waitforchild…” -
What solutions have you tried so far? Did you look for solutions on the Developer Hub? I tried anothers methods of get the player with a touched event but that was useless, I am about 4 hours trying to write this only function (yes, I known that’s a lot of time for a simple function), here’s my code on the principal module Script.
function Tycoon:Init(player,Doro,text)
local Player = game.Players:GetPlayerFromCharacter(player.Parent)
local own = Player:WaitForChild("own",5)
if not own then
self.Owner = player
Doro.SurfaceGui.Claim.TextTransparency = 1
text.Text = Player.DisplayName
own = true
else return end
end
on the script of the bollean value:
game.Players.PlayerAdded:Connect(function(player)
local own = Instance.new("BoolValue")
own.Parent = player
own.Name = "own"
own.Value = false
end)
the door’s script:
local Tycoon = require(game:GetService("ServerScriptService").General)
local doro = script.Parent.Doro
local text = script.Parent.Parent.BillboardGui.TextLabel
Tycoon.new()
doro.Touched:Connect(function(player)
Tycoon:Init(player,doro, text)
end)