I’m making a game and I have a local script that isn’t picking up touched events.
for i,v in pairs(game.Players.LocalPlayer.leaderstats.BackPacks:GetChildren()) do
local shopbutton = game.StarterGui.Templates.ItemButton:Clone()
shopbutton.Parent = script.Parent
shopbutton.Text = v.Name
shopbutton.Price.Text = v.Price.Value .. "BoomBux"
local function updateData(item)
if item.Purchased.Value == true then
if item.Equipted.Value == true then
shopbutton.TextLabel.Text = "Equipped"
else
shopbutton.TextLabel.Text = "Equip"
end
end
end
shopbutton.MouseButton1Click:Connect(function(plr)
shopbutton.TextLabel:TweenPosition(UDim2.new(0, 0,1, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quint,0.3)
updateData(v)
wait(1)
shopbutton.TextLabel:TweenPosition(UDim2.new(0, 0,0, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quint,0.3)
end)
shopbutton.TextLabel.MouseButton1Click:Connect(function()
updateData(v)
shopbutton.TextLabel:TweenPosition(UDim2.new(0, 0,0, 0),Enum.EasingDirection.In,Enum.EasingStyle.Quint,0.3)
local purchase = game.ReplicatedStorage.Remotes.Purchase
local plr = game.Players.LocalPlayer
purchase:FireServer(v)
purchase.OnClientEvent:Connect(function()
game.StarterGui.Sounds.Purchase:Play()
shopbutton.BackgroundColor3 = Color3.new(0, 1, 0)
wait(0.3)
shopbutton.BackgroundColor3 = Color3.new(1, 1, 1)
end)
end)
end
game.Workspace.Packpart.Touched:Connect(function(toucher)
print("e")
if toucher.Parent == game.Players.LocalPlayer.Character then
script.Parent:TweenPosition(UDim2.new(0.065, 0,0, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Elastic,0.8)
end
end)
script.Parent.CloseShop.MouseButton1Click:Connect(function()
script.Parent:TweenPosition(UDim2.new(0.065, 0,1.1, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quint,0.8)
end)
game.Workspace.Packpart.Touched:Connect(function()
print("eeeeeeee")
end)
Here is is
I have put prints and tested every part and most of them function correctly. The only part that isnt is this
game.Workspace.Packpart.Touched:Connect(function(toucher)
print("e")
if toucher.Parent == game.Players.LocalPlayer.Character then
script.Parent:TweenPosition(UDim2.new(0.065, 0,0, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Elastic,0.8)
end
end)
script.Parent.CloseShop.MouseButton1Click:Connect(function()
script.Parent:TweenPosition(UDim2.new(0.065, 0,1.1, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quint,0.8)
end)
game.Workspace.Packpart.Touched:Connect(function()
print("eeeeeeee")
end)
This part isn’t picking up the touched event.
I’ve used this same touched event with another part from the workspace in other local script and cant find out why this one is different.
Don’t mind
game.Workspace.Packpart.Touched:Connect(function()
print("eeeeeeee")
end)
It was to test.
I hope there is an easy fix to this problem.