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.
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)
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)
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)