I spent an hour trying to fix this script I have no idea why it’s not working help!
– the script checks if a player has a gamepass then it gives the player an arrow to a destination.
Thank you everyone who helped me!)
local function compas()
local ArrowModel = game.ReplicatedStorage:WaitForChild(“ArrowModel”):Clone()
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
ArrowModel.Parent = workspace
ArrowModel.Name = player.Name…“'s Arrow”
game:GetService(“RunService”).RenderStepped:Connect(function()
ArrowModel.PrimaryPart.CFrame = CFrame.new(char.HumanoidRootPart.Position, workspace.ArrowPart.Position)
end) end
function Close(player)
if game:GetService(“MarketplaceService”):UserOwnsGamePassASync(player, 5694417) then
compas()
else
script:Destroy()
end
end
local Players = game:GetService(“Players”)
Players.PlayerAdded:connect(Close)
Sorry I split them up into 3 main parts the first are the variables, second where the arrow is made and attached to the local player, and the third where it checks if the player has a gamepass and gives them the arrow. (the arrow is hidden until it finds the gamepass)
(not contributing to the problem)
if you want your post to look better you can wrap the code like this:
so it looks like:
print("hi")
i also recommend to indent the script like @ZINTICK said due to it being really hard to read (if you don’t know what it is you can look it up, there is an auto-indent setting in studio). indenting scripts makes it much easier to find bugs ^^
local function compas()
local ArrowModel = game.ReplicatedStorage:WaitForChild(“ArrowModel”):Clone()
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
ArrowModel.Parent = workspace
ArrowModel.Name = player.Name…"'s Arrow"
game:GetService(“RunService”).RenderStepped:Connect(function()
ArrowModel.PrimaryPart.CFrame = CFrame.new(char.HumanoidRootPart.CFrame, workspace.ArrowPart.CFrame)
end)
end
function Close(player)
if game:GetService(“MarketplaceService”):UserOwnsGamePassASync(player.UserId, 5694417) then
compas()
else
script:Destroy()
end
end
local Players = game:GetService(“Players”)
Players.PlayerAdded:connect(Close)
That’s why it doesn’t work, PlayerAdded doesn’t work for your localPlayer in a localscript, your palyer is added to fast before the script detects it, use this
local player = game.Players.LocalPlayer
local function compas()
local ArrowModel = game.ReplicatedStorage:WaitForChild(“ArrowModel”):Clone()
local char = player.Character or player.CharacterAdded:Wait()
ArrowModel.Parent = workspace
ArrowModel.Name = player.Name…"'s Arrow"
game:GetService("RunService").RenderStepped:Connect(function()
ArrowModel:SetPrimaryPartCFrame(CFrame.new(char.HumanoidRootPart.Position, workspace.ArrowPart.Position))
end)
end
if game:GetService("MarketplaceService"):UserOwnsGamePassASync(player.UserId, 5694417) then
compas()
else
script:Destroy()
end
There was some mistakes with your script I fixed them, but still I don’t see any errors nor the arrow.
local function compas()
local ArrowModel = game.ReplicatedStorage:WaitForChild("ArrowModel"):Clone()
local char = player.Character or player.CharacterAdded:Wait()
ArrowModel.Parent = workspace
ArrowModel.Name = player.Name .." 's Arrow"
game:GetService("RunService").RenderStepped:Connect(function()
ArrowModel:SetPrimaryPartCFrame(CFrame.new(char.HumanoidRootPart.Position, workspace.ArrowPart.Position))
end)
end
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 5694417) then
compas()
else
script:Destroy()
end