SO, what I’m trying to do is make a toucher, that when you touch it you get a car shop like gui thing so you can select a car to buy, BUT the script for the toucher isn’t working. Here is the script I’ve been using.
function Touched(Part)
if Part then
if Part.Parent:FindFirstChild("Humanoid") and Part.Name == "Torso" then
if game.Players:FindFirstChild(Part.Parent.Name) then
if game.Players:FindFirstChild(Part.Parent.Name).PlayerGui:FindFirstChild("LucasChat") == nil then
local NewGui = game.ReplicatedStorage.Guis.Chats.LucasChat:Clone()
NewGui.Parent = game.Players:FindFirstChild(Part.Parent.Name).PlayerGui
end
end
end
end
end
script.Parent.Touched:connect(Touched)
I’ve tried changing the scripts multiple times but it doesn’t work. Here is also the script I used in Local Script for the “VehicleCatalog” GUI.
for A = 1,20 do
wait()
script.Parent.BackFrame.BackgroundTransparency = 1-(A/20)
end
script.Parent:WaitForChild("Catalog")
script.Parent:WaitForChild("BuyItem")
script.Parent:WaitForChild("NotEnoughMoney")
local BuyItem = script.Parent.BuyItem:Clone()
script.Parent.BuyItem:Destroy()
local NotEnoughMoney = script.Parent.NotEnoughMoney:Clone()
script.Parent.NotEnoughMoney:Destroy()
local ItemFrame = script.Parent.Catalog.CatalogFrame.Item:Clone()
script.Parent.Catalog.CatalogFrame.Item:Destroy()
local NewPlatform = game.ReplicatedStorage.ServerStats.VehicleCatalogModel:Clone()
NewPlatform.Parent = workspace workspace.CurrentCamera.CameraType = "Scriptable"
Ang = 0
Exit = false
Item = nil
game.Players.LocalPlayer.Character.Humanoid.Died:connect(function()
if NewPlatform then
NewPlatform:Destroy()
end
if Item then
Item:Destroy()
end
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Custom"
end)
game:GetService("RunService").RenderStepped:connect(function()
if Exit == false then
Ang = Ang + 0.002
workspace.CurrentCamera.CoordinateFrame = CFrame.new(0,1018,0)*(CFrame.Angles(0,Ang,0)*CFrame.new(-5,0,25)*CFrame.Angles(math.rad(-30),0,0))
end
end)
for A = 1,20 do
wait()
script.Parent.BackFrame.BackgroundTransparency = A/20
end
script.Parent.Catalog:TweenPosition(UDim2.new(0,0,0.3,0),1,1,1)
local All = game.ReplicatedStorage.ServerStats.Vehicles:GetChildren()
script.Parent.Catalog.CatalogFrame.CanvasSize = UDim2.new(0,0,0,(#All*50)+10)
for A = 1,#All do
local NewItemFrame = ItemFrame:Clone()
NewItemFrame.Parent = script.Parent.Catalog.CatalogFrame
NewItemFrame.Position = UDim2.new(0,5,0,-45+(A*50))
NewItemFrame.Text = All[A].Name
NewItemFrame.Thumbnail.Image = game.ReplicatedStorage.ServerStats.VehicleImages:FindFirstChild(All[A].Name).Value
if All[A].Price.Value > 0 then
NewItemFrame.Price.Text = All[A].Price.Value
else
NewItemFrame.Price.Text = -All[A].Price.Value.."R"
NewItemFrame.ImageLabel.Image = "http://www.roblox.com/asset/?id=347347731"
end
if game.ReplicatedStorage.PlayerStats:FindFirstChild(game.Players.LocalPlayer.Name).Vehicles:FindFirstChild(All[A].Name) then
NewItemFrame.Style = 3
elseif game.ReplicatedStorage.PlayerStats:FindFirstChild(game.Players.LocalPlayer.Name).Gamepasses:FindFirstChild(All[A].Name) then
NewItemFrame.Style = 3
else
NewItemFrame.Style = 5
end
NewItemFrame.MouseEnter:connect(function()
if Item ~= nil then
Item:Destroy()
end
Item = game.ReplicatedStorage.ServerStats.Vehicles:FindFirstChild(All[A].Name):Clone()
Item.Parent = workspace
if All[A].Name == "Monotracer" then
Item:SetPrimaryPartCFrame(CFrame.new(NewPlatform.Main.Position+Vector3.new(0,2,-8))*CFrame.Angles(0,math.rad(180),0))
elseif All[A].Name == "Golfcart" then
Item:SetPrimaryPartCFrame(CFrame.new(NewPlatform.Main.Position+Vector3.new(0,2,0)))
elseif All[A].Name == "Jeep" then
Item:SetPrimaryPartCFrame(CFrame.new(NewPlatform.Main.Position+Vector3.new(0,2,0)))
elseif All[A].Name == "Limo" then
Item:SetPrimaryPartCFrame(CFrame.new(NewPlatform.Main.Position+Vector3.new(0,2,0)))
end
end)
NewItemFrame.MouseButton1Click:connect(function()
if All[A].Price.Value > 0 then --PP Purchase
if script.Parent:FindFirstChild("BuyItem") == nil and script.Parent:FindFirstChild("NotEnoughMoney") == nil and NewItemFrame.Style == Enum.ButtonStyle.RobloxRoundDropdownButton then
local NewBuyItem = BuyItem:Clone()
NewBuyItem.SubFrame.TextLabel.Text = "Do you want to buy the vehicle "..All[A].Name.." for "..All[A].Price.Value.."PP?"
NewBuyItem.Visible = true
NewBuyItem.Parent = script.Parent
NewBuyItem.SubFrame.Buy.MouseButton1Click:connect(function()
if game.ReplicatedStorage.PlayerStats:FindFirstChild(game.Players.LocalPlayer.Name).Money.Value >= All[A].Price.Value and All[A].Price.Value >= 0 then
game.ReplicatedStorage.ServerStats.ChangeMoney:FireServer(-(All[A].Price.Value),math.floor(math.sqrt(game.ReplicatedStorage.ServerStats.CurrentID.Value))+1337)
game.ReplicatedStorage.ServerStats.BuyVehicle:FireServer(All[A].Name)
NewBuyItem:Destroy()
NewItemFrame.Style = 3
else
local NewNotEnoughMoney = NotEnoughMoney:Clone()
NewNotEnoughMoney.Parent = script.Parent
NewNotEnoughMoney.Visible = true
NewBuyItem:Destroy()
NewNotEnoughMoney.SubFrame.Ok.MouseButton1Click:connect(function()
NewNotEnoughMoney:Destroy()
end)
end
end)
NewBuyItem.SubFrame.Cancel.MouseButton1Click:connect(function()
NewBuyItem:Destroy() end)
end
else --Gamepass Purchase
if script.Parent:FindFirstChild("BuyItem") == nil and script.Parent:FindFirstChild("NotEnoughMoney") == nil and NewItemFrame.Style == Enum.ButtonStyle.RobloxRoundDropdownButton then
local NewBuyItem = BuyItem:Clone()
NewBuyItem.SubFrame.TextLabel.Text = "Do you want to buy the vehicle "..All[A].Name.." for "..-All[A].Price.Value.." Robux?"
NewBuyItem.Visible = true
NewBuyItem.Parent = script.Parent
NewBuyItem.SubFrame.Buy.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptPurchase(game.Players.LocalPlayer,361204620)
end)
NewBuyItem.SubFrame.Cancel.MouseButton1Click:connect(function()
NewBuyItem:Destroy()
end)
end
end
end)
end
script.Parent.Catalog.Back.MouseButton1Click:connect(function()
script.Parent.Catalog:TweenPosition(UDim2.new(0,-300,0.3,0),1,1,1)
wait(1)
for A = 1,20 do
wait()
script.Parent.BackFrame.BackgroundTransparency = 1-(A/20)
end
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Custom"
if NewPlatform ~= nil then
NewPlatform:Destroy()
end
if Item ~= nil then
Item:Destroy()
end
for A = 1,20 do
wait()
script.Parent.BackFrame.BackgroundTransparency = A/20
end
if game.Players.LocalPlayer.PlayerGui:FindFirstChild("LucasChat") then
game.Players.LocalPlayer.PlayerGui:FindFirstChild("LucasChat").Exit:FireServer()
end
script.Parent:Destroy()
end)
If you THINK or KNOW how to fix this please, tell me. Thanks!