Assistance with tool giving

Hi, I’m working on a self check-in machine.

I’m trying to get it to give out a tool to the player but it doesn’t seem to be working.

Script is a serverscript.

Any help is appreciated

--]] TOOLS

function GiveStandard(PlayerObject)
	local StandardPass = game.ReplicatedStorage.SCI.Tools.Standard:Clone()
	if not PlayerObject.Backpack:FindFirstChild("Standard") then
		StandardPass.Parent = (PlayerObject.Backpack)
	end
end



--]] FINISH SCREEN



finishscreen.button.TextButton.MouseButton1Click:Connect(function(Player)
	toolsensor.TicketDispense:Play()
	 wait(2)
	  local tween = tweenService:Create( AnimationFrame, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { BackgroundTransparency = 0 } )
	   tween:Play()
	wait(0.4)
	
	GiveStandard(Player)
	
	print("Test")
	
	   finishscreen.Visible = false
	   rebootingscreen.Visible = true
	   local tween = tweenService:Create( AnimationFrame, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { BackgroundTransparency = 1 } )
	   tween:Play()
	   wait(2)
	   resetSystem()
	   print("system Reset")
end)

What’s the output of your script? Is Test ever printed?
I can’t really help you because I don’t know much about your game.
Try Debugging Tools.

No test isn’t printed.

though it says something about “attempt to index nil with ‘Backpack’”

Did you add variables like
local player = game.Players.LocalPlayer
local Backpack = game:GetService(“Backpack”)

Wouldn’t that only be if the script was a localscript?

1 Like

This is giving a player with a tool so this will need to be a local script because I think your giving a tool to a player and not to every player right???

Its a little hard to explain, but to put it shortly, it has to be done in this server script. cant be a local script as that would be outside the main handler. It is possible to-do within a server script, im just struggling to get it to work

It’s 2 am right now so sorry if I get this wrong or it’s not the best explanation, but (assuming that it’s a SurfaceGui), you can’t get the player from a SurfaceGui. Since it’s a server script you’d need to make it a local script and use a remote event to give the tool from the server.

It’s on a server script because it needs to be shown to every player

Hey, thanks.

Though i was doing it at like 4am so I just gave up in the end and had it print a physical ticket which can be taken with a proximity prompt, which is some ways is better than it just magically appearing in your inventory.

thanks though.

1 Like