Pick Up Gui dosent work?

Hey, im working on an horror game, and i want to make so when you pick up something, it will pop up an text, i used events, but it dosen’t work, is there any issues?

Server Script:

script.Parent.Triggered:Connect(function(p)
	local toolName = "Flaslight" 
	game.ReplicatedStorage.Flashlight:Clone().Parent = p.Backpack
	game.ReplicatedStorage.PickupRe:FireClient(p, toolName)
end)

Local Script:

game.ReplicatedStorage.PickupRe.OnClientEvent:Connect(function(p, toolname)
	local temp = game.ReplicatedStorage:WaitForChild("ActionText")
	local text = temp:Clone()
	local ts = game:GetService("TweenService")
	local i = TweenInfo.new(3)
	local i2 = TweenInfo.new(2)
	local g = {Position = UDim2.new(.5, 0, -0.1, 0)}
	local g2 = {TextTransparency = 1}
	local t = ts:Create(text, i, g)
	local t2 = ts:Create(text, i2, g2)
	text.Parent = p.PlayerGui
	text.Text = "+1 "..toolname
	t:Play()
	t2:Play()
	t.Completed:Wait()
	text:Destroy()
end)

Also, i have an console error:

Players.elepunto3993.PlayerGui.PickUpGui.LocalScript:12: attempt to concatenate string with nil

i dont know if the toolName variable is passing well?

concatenate string with nil means that its trying to combine “+1” and a variable with nothing in it

you put the player as the first argument from the server script to identify which player to send it to, and the rest are arguments in the client event

that means that “p” on the client script is actually the toolname, and the variable “toolname” has nothing in it

game.ReplicatedStorage.PickupRe.OnClientEvent:Connect(function(toolname)
	local temp = game.ReplicatedStorage:WaitForChild("ActionText")
	local text = temp:Clone()
	local ts = game:GetService("TweenService")
	local i = TweenInfo.new(3)
	local i2 = TweenInfo.new(2)
	local g = {Position = UDim2.new(.5, 0, -0.1, 0)}
	local g2 = {TextTransparency = 1}
	local t = ts:Create(text, i, g)
	local t2 = ts:Create(text, i2, g2)
	text.Parent = p.PlayerGui
	text.Text = "+1 "..toolname
	t:Play()
	t2:Play()
	t.Completed:Wait()
	text:Destroy()
end)
1 Like

it worked, thank you!


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.