Alright get a load of this. Im working on a tycoon with a friend of mind and when I test it on studio when the tycoon stuff reach the part that sells them it works. Though when the other guy tests it it doesnt work. When I go into team test it doesn’t work. When I click test under the test tab it works. When i play it in normal roblox it doesn’t work. There are no errors in the output. What the heck is going on!?!?
Here is the script:
local function addPoints(points)
local player = tycoon.TycoonOwner.Value
if player then
local money = player.leaderstats.Tokens
money.Value = money.Value + points
end
end
local function sellObject(part)
if part.Parent.Name == "Water pistol" then
addPoints(1)
part.Parent:Destroy()
elseif part.Parent.name == "cWater pistol" then
addPoints(3)
part.Parent:Destroy()
elseif part.Parent.name == "uWater pistol" then
addPoints(6)
part.Parent:Destroy()
elseif part.Parent.name == "uuWater pistol" then
addPoints(10)
part.Parent:Destroy()
end
end
local function onTouched(otherPart)
if otherPart:IsDescendantOf(objectsFolder) then
sellObject(otherPart)
end
end
deposit.Touched:Connect(onTouched)
The claim button turns the value to the player’s name. So the tycoon knows who to give money.
I doubt that’s the issue, but Idk.
local button = script.Parent
local tycoon = script.Parent.Parent
local function getPlayerFromPart(part)
local character = part.Parent
if character then
local player = game.Players:GetPlayerFromCharacter(character)
return player
end
end
local function assignTycoon(player)
local playerValue = Instance.new("ObjectValue")
playerValue.Name = "TycoonOwned"
playerValue.Value = tycoon
playerValue.Parent = player
tycoon.TycoonOwner.Value = player
end
local function onTouched(otherPart)
local player = getPlayerFromPart(otherPart)
if player then
local tycoonOwned = player:FindFirstChild("TycoonOwned")
if not tycoonOwned then
assignTycoon(player)
button:Destroy()
end
end
end
button.Touched:Connect(onTouched)