As the error states, Position is not a valid memeber of the folder. This code doesn’t appear to be requesting the position of anything. Is this error from another script?
game.Player.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if msg == "!spawn cart" then
if player.GetRoleInGroup(10968280) >= 240 then
local clone = game.ReplicatedStorage.GolfCart:Clone()
clone.Parent = workspace
clone.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame + Vector3.new (5, 0, 0)
else
print("sorry u cant spawn cart noob")
end
end
end)
end)
Now try and tell me if this will print anything in the output
game.Player.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if msg == "!spawn cart" then
if player.GetRoleInGroup(10968280) >= 240 then
print("Car has spawned")
local clone = game.ReplicatedStorage.GolfCart:Clone()
clone.Parent = workspace
clone.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame + Vector3.new (5, 0, 0)
else
print("sorry u cant spawn cart noob")
end
end
end)
end)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if msg == "!spawn cart" then
if player:IsInGroup(10968280) then
if player:GetRankInGroup(10968280) >= 240 then
print("cart has spawned")
local clone = game.ReplicatedStorage.GolfCart:Clone()
clone.Parent = workspace
clone.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame + Vector3.new (5, 0, 0)
else
print("sorry u cant spawn cart noob")
end
else
print("player is not in group!")
end
end
end)
end)
it spawned. but i dont know where it is. i think its because the HumanoidRootPart is from a dummy because that is what i based the script out of. is there a way to teleport the golf cart next to you?
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if msg == "!spawn cart" then
if player:IsInGroup(10968280) then
if player:GetRankInGroup(10968280) >= 240 then
print("cart has spawned")
local clone = game.ReplicatedStorage.GolfCart:Clone()
clone.Parent = workspace
clone.CFrame = player.Character.HumanoidRootPart.CFrame + Vector3.new (5, 0, 0)
else
print("sorry u cant spawn cart noob")
end
else
print("player is not in group!")
end
end
end)
end)
You accidentally put HumanoidRootPart.CFrame on the golf cart that’s why it’s position was never moved
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if msg == "!spawn cart" then
if player:IsInGroup(10968280) then
if player:GetRankInGroup(10968280) >= 240 then
print("cart has spawned")
local Pos = player.Character.PrimaryPart.Position
local newPos = Vector3.new(Pos.X + 5,Pos.Y ,Pos.Z)
local clone = game.ReplicatedStorage.GolfCart:Clone()
clone:PivotTo(clone.PrimaryPart.CFrame:Lerp(newPos, Pos, 1))
clone.Parent = workspace
else
print("sorry u cant spawn cart noob")
end
else
print("player is not in group!")
end
end
end)
end)