local P = script.Parent
local player = P.Parent.Parent
local index = 1
local Sdat = script.Parent.Parent.Parent.ShipData
local vehicles = {
{
"Cruiser",
1378561713
},
{
"Piercer",
236481762
},
}
wait(0.5)
local bg = P.BG
function SetInformation(index)
bg.I.Image = "http://www.roblox.com/thumbs/asset.ashx?assetId="..vehicles[index][2].."&x=420&y=420"
bg.T.Text = vehicles[index][1]
end
local locked = false
bg.S.MouseButton1Click:connect(function()
if (locked) then return end
locked = true
local vehicleName = player.Name.."Ship"
if (not workspace:FindFirstChild(vehicleName)) then
if Sdat:FindFirstChild(vehicles[index][1]) == true then
local model = game.ServerStorage.Vehicles:FindFirstChild(vehicles[index][1]):Clone()
model.Name = vehicleName
model.Parent = game.Workspace
model:MakeJoints()
model:MoveTo(player.Character.HumanoidRootPart.Position + Vector3.new(20, 0, 0))
bg.Visible = false
else
bg.S.Text = "You can only have one ship at a time."
wait(1)
bg.S.Text = "Spawn"
end
locked = false
else print "Player does not own selected ship."
end)
bg.B.MouseButton1Click:connect(function()
index = index - 1
if (index < 1) then index = #vehicles end
SetInformation(index)
end)
bg.N.MouseButton1Click:connect(function()
index = index + 1
if (index > #vehicles) then index = 1 end
SetInformation(index)
end)
SetInformation(index)
the problem in this script is that
if a bool value is true then it copies the model
if its false then it prints
the name of the boolvalue is the name of the ship which the player selected
however this doesnt work for me
(For context Sdat is a folder in the player which contains boolvalues in which the names are of the ships. If the boolvalue of the ship == true it spawns that particular ship)
