I think its because of "LocalPlayer" but I am not sure. I am trying to move the TarantulaPet to the players character folder.
local gamePassID = 0000000 local function onPlayerAdded(player) local hasPass = false local success, message = pcall(function() hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID) end) if not success then warn("Error while checking if player has pass: " .. tostring(message)) return end if hasPass == true then player.CharacterAdded:connect(function(character) game.ServerStorage:FindFirstChild("TarantulaPet"):Clone().Parent = game.Players.LocalPlayer.Character end) end end Players.PlayerAdded:Connect(onPlayerAdded)
You don't need to use game.Players.LocalPlayer.Character
, because the CharacterAdded
event has the character
argument passed in already. Even then, this should be a server script, so you can't use LocalPlayer in a server script.
if hasPass then -- you don't need == true player.CharacterAdded:Connect(function(character) -- change connect to Connect game.ServerStorage:FindFirstChild("TarantulaPet"):Clone().Parent = character end) end
Hope this helps! :)