I want to make a code that when the brick is touched, a car appears infront of the players character, but right now my code isnt working. May you please help me? Also, if my code is bad sorry its because I started scripting 5 days ago... :/
Code:
local crvpart = game.Workspace.CRV local v = game.ServerStorage["CR-V"] local character = game.Players.LocalPlayer.Character crvpart.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local vly = v:Clone() vly.Parent = game.Workspace vly:MoveTo(character.UpperTorso.Position + Vector3.new(0,0,10)) end end)
If you want to do it without LocalScript then
function PlayerAdded (Player) -- declare PlayerAdded as a function and Player as variable (in this case is the player) local crvpart = game.Workspace.CRV -- define variable crvpart as part CRV local v = game.ServerStorage["CR-V"] -- define v as stuff CR-V local character = Player.Character -- define character as the player (if testing mode, Player1) crvpart.Touched:connect(function(hit) -- function run when something touch it. if hit.Parent:FindFirstChild("Humanoid") then -- if player has a humanoid local vly = v:Clone() -- clone v vly.Parent = game.Workspace --- define cloned item parent as workspace vly:MoveTo(character.UpperTorso.Position + Vector3.new(0,0,10)) -- move to the desired location end end) end game.Players.PlayerAdded:connect (PlayerAdded) -- Function run when a player entered
DISCLAIMER: As I type this from from my phone, I have not test it yet.