Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How come this script is destroying a model when the player IS in the game?

Asked by 7 years ago

Here's my script;

local Coin = script.Parent
local Owner = Coin.Parent:WaitForChild("Owner")
local MiningSet = Coin.Parent

game.Players.PlayerAdded:connect(function()
    wait(10)
    while true do
        wait(1)
        local CloneCoin = Coin:Clone()
        local Player = game.Players:FindFirstChild(Owner.Value)
        if not Player then
            MiningSet:Destroy()
        else
            wait(1)
            Player:WaitForChild("PlayerStatus").Coins.Value = Player:WaitForChild("PlayerStatus").Coins.Value + 1
        end
    end
end)

The Owner.Value is BlackOrange3343. When I join the game and wait it just destroy's it self. Even though the player is in the game.

1 answer

Log in to vote
1
Answered by 7 years ago

Have you tested this in player? The most likely issue is that your testing this in studio and in studio, you are called 'Player1' no matter what. If the issue persists in Roblox player, check to make sure all your components correspond in your script. Also you might want to use a non local script in the server script service to handle player joining as a function.

Hope this helped

0
Thanks BlackOrange3343 2676 — 7y
Ad

Answer this question