Part touch activate UI not working

I’m trying to make a part that once touched a UI will appear, but it’s not working.

I’ve tried multiple ways.

Code:

local ts = game:GetService("TweenService")
local ti = TweenInfo.new(0.2, Enum.EasingStyle.Back)

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		print("Humanoid found")
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		game.ReplicatedStorage.Merchant.OpenMerchant1:FireClient(plr)
	else
		warn("No humanoid found.")
		end

end)

I’ve also tried making it directly visible using the script yet nothing works.

1 Like

1st) does the print work? 2nd) can you show us the client side code?
Also remove that player argument you don’t need it, it might be the one breaking the code


script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		print("Humanoid found")
		game.ReplicatedStorage.Merchant.OpenMerchant1:FireClient()
	else
		warn("No humanoid found.")
	end
end)
2 Likes

Yes, the print does work, it says “Humanoid Found”.

Client Side Code:

local event = game.ReplicatedStorage.Merchant.OpenMerchant1
local ui = script.Parent
local open = ui.Parent.MainOpen
local close = ui.Parent.MainClose
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(0.2, Enum.EasingStyle.Back)
local tween = ts:Create(ui, ti, { Position = UDim2.new(open.Position.X, open.Position.Y)})

event.OnClientEvent:Connect(function()
	ui.Visible = true
	tween:Play()
end)
1 Like

replace the server side code with what i gave you
(fixed the backsteps)

1 Like

Doesn’t fire client need a player to fire for if I want it to fire for just one client instead of every client?

1 Like

I get this error.
image
It says argument one is missing.

2 Likes

Yeah just add a random argumnt for that

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		print("Humanoid found")
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		game.ReplicatedStorage.Merchant.OpenMerchant1:FireClient(plr)
	else
		warn("No humanoid found.")
	end
end)
1 Like

also you should be adding the player argument inside that

1 Like

It is working now, I accidentally had Enabled set to false so I could publish a minor bug fix without this being in there until it’s fully ready.

1 Like

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