If you are printing inside the while loop try putting it before the while loop
found the issue, you miss spelled “Item”.
you must also define your cloned item variable inside the function inside the spawn(function()
local Players = game:GetService(“Players”)
local ServerStorage = game:GetService(“ServerStorage”)
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message == “/a cat” then
Player.CharacterAppearanceLoaded:Connect(function(Char)
spawn(function()
task.wait(3)
local Item = ServerStorage.ChatSpawnItems.Cat:Clone()
Item.Parent = workspace
Item:PivotTo(Char.HumanoidRootPart:GetPivot() * CFrame.new(5,0,0))
end)
end)
end)
If you want to position something directly in front of the player, use exclusively CFrames and not Vector3, since those are not relative and won’t change their position depending on where the player is looking.
Item:PivotTo(Char.HumanoidRootPart.CFrame * CFrame.new(5,0,0))
(Not really sure if that specific CFrame will put it in front of the character, but you can just change it, pretty much trial and error)
also not sure why you used PlayerAdded event twice.
Because im typing on mobile, i made an error.
Did you set PrimaryPart of your model?
no need to a primarypart as long as we’re using PivotTo
Even with everybodys suggestions its not seeming to work.
local Players = game:GetService(“Players”)
local ServerStorage = game:GetService(“ServerStorage”)
local Item = ServerStorage.ChatSpawnItems.Cat:Clone()
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if message == cat then
print(“Test”)
Player.CharacterAppearanceLoaded:Connect(function(Char)
spawn(function()
item.Parent = workspace
Item.PiviotTo(Char.HumanoidRootPart.CFrame * CFrame.new(5,0,0))
end)
end)
local Players = game:GetService(“Players”)
local ServerStorage = game:GetService(“ServerStorage”)
local Item = ServerStorage.ChatSpawnItems.Cat:Clone()
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if message == "cat" then -- should be "cat"
print(“Test”)
Player.CharacterAppearanceLoaded:Connect(function(Char)
spawn(function()
item.Parent = workspace -- Should be Item.Parent
Item.PivotTo(Char.HumanoidRootPart.CFrame * CFrame.new(5,0,0))
end)
end)
you still have some errors.
Change if message == cat then to if message == “cat” then
Item to item
PiviotTo to PivotTo
theres no use for the quotations??? as for the other ill fix that.
edit: nvm i see it now LOL!
another edit: the piviot was a spelling mistake my bad.
there is actually an use that will return and error, you’re like trying to check if the message is equal to a variable.
Yea i edited my post, sorry for the misunderstanding!
The reason it says /a cat is because its supposed to act as a command.
you can still change “cat” to “/a cat”
Even with this nothing happens, sorry. (no errors, no anything.)
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(char)
Player.Chatted:Connect(function(Message)
if Message == "cat" then
spawn(function()
local Item = ServerStorage.Cat:Clone()
Item.Parent = workspace
Item:PivotTo(char.HumanoidRootPart.CFrame + char.HumanoidRootPart.CFrame.LookVector * 5)
end)
end
end)
end)
end)
Seriously recommed getting a keyboard!
how is there no errors while there is literally an error which is “message”