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

First Time Making a house owner script?

Asked by 6 years ago

I am trying to create a crime game related to GTA V. I want to be the first Robloxian to create a roblox game similar to GTA. The only thing I need help with is the house. I want players to have a free house when they first start the game. But I have errors with my script:

game.Players.PlayerAdded:connect(function(player) for i,v in ipairs(game.Players:GetChildren()) do wait()

local owner = Instance.new("StringValue") owner.Parent = v owner.Name = v.Name

script.players.Value = script.players.Value +1 --ERROR I want the value to add by 1 but it kept adding by 2's

    wait(1)

print("Players: "..script.players.Value) -------------Houses---------------------------- local num = Instance.new("NumberValue") num.Parent = v num.Name = "myhouse" num.Value = script.players.Value print(v.Name.." house"..num.Value) wait(1) ----------------teleporting players home------------------- if v.myhouse.Value == 1 then v.Character.Torso.CFrame = workspace.MyHouse.spawn.h1.CFrame end if v.myhouse.Value == 2 then v.Character.Torso.CFrame = workspace.MyHouse.spawn.h2.CFrame end if v.myhouse.Value == 3 then v.Character.Torso.CFrame = workspace.MyHouse.spawn.h3.CFrame end if v.myhouse.Value == 4 then v.Character.Torso.CFrame = workspace.MyHouse.spawn.h4.CFrame

end

for i,c in ipairs(workspace.MyHouse.players:GetChildren()) do print(c.Name) if c.Name == player.Name then

end
end

end end)

the second script:

game.Players.PlayerRemoving:connect(function(p) for i,v in ipairs(game.Players:GetChildren()) do

game.workspace.MyHouse.players.Value = game.workspace.MyHouse.players.Value -1 ---------------------------------------------Error the value kept substracting by 2's instead of 1

print("Players: "..game.workspace.MyHouse.players.Value) for i,c in ipairs(game.workspace.MyHouse.players:GetChildren()) do if c.Name == p.Name then c:Destroy() end for i,z in ipairs(workspace.MyHouse.players:GetChildren()) do print(z.Name) end end end

end)

1 answer

Log in to vote
0
Answered by
thesit123 509 Moderation Voter
6 years ago

Here is a great video by AlvinBLOX.

Ad

Answer this question