Touched Event not working on Union

  • What do I want to achieve?
    So, I have this Local Script inside a union part. And in that script I have a touched event, which fires when a remote event on the server.

  • What is the issue?
    So the issue is that, The Touched Event is not getting fired in a Union Event.
    Note that - I am using a Local Script

  • What solutions have I tried so far?
    Yes, I have looked for solutions on google, as well as on The Roblox Developer Forum. So upon viewing other threads/posts, they basically had a Server Script inside the union. And they also made the union unanchored. So I also made my union part unanchored. I also tried making my Local Script into Server Script. But I got more issues. So can’t do that.

Here is my Client Side Code - (It is located inside the union part)

local HasClaimed = script.Parent.Parent.Parent:WaitForChild("HasClaimed")
HasClaimed.Changed:Connect(function()
	if HasClaimed.Value == true then
		local PurchaseRequest = game.ReplicatedStorage.events.PurchaseRequest
		local PurchaseAccept = game.ReplicatedStorage.events.PurchaseAccepted
		local Owner = script.Parent.Parent.Parent.Parent.Owner
		script.Parent.Touched:Connect(function(hit)
			if hit.Parent.Name == Owner.Value then
				local Item = script.Parent.Parent.Item
				local Price = script.Parent.Parent.Price
				PurchaseRequest:FireServer(Item.Value, Price.Value)
				PurchaseAccept.OnClientEvent:Connect(function()
					script.Parent.Parent:Destroy()
				end)
			end
		end)
	end
end)

And Here is my Server Side Code -

-- Handles Purchasing
PurchaseRequest.OnServerEvent:Connect(function(Plr, Item, Price)
	local Player = game.Players:FindFirstChild(Plr)
	local Stuff = PurchasableItems:FindFirstChild(Item)
	if Player.leaderstats.Cash.Value >= Price then
		-- Deducting the price from the player's cash
		Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value - Price
		-- Making the Item Appear and Making it work
		for _, v in pairs(Stuff:GetChildren()) do
			if v:IsA("UnionOperation") or v:IsA("Part") then 
				v.Transparency = 0
				v.CanCollide = true
				v.CanTouch = true
			elseif v:IsA("Script") then 
				v.Enabled = true
				v.Parent:WaitForChild("Work").Value = true
			end 
		end
		-- Putting it in the BoughtItems Folder
		Stuff.Parent = BoughtItems
		-- Making the Button disappear
		PurchaseAccepted:FireClient()
	end
end)

Please Help me out here, so that I don’t have to make my local script into a Server script.

Thanks,
TSMN

2 Likes

I would download the union, and reimport it as a meshpart. Not only to save performance but to properly utilize the render fidelity property on the meshpart. Not sure if unions have render fidelity, so that could be the first option.

Also try adding a debug statement such as a print to the intial .touched event to see if it’s actually working.

2 Likes

Touched event only works in a Script.

2 Likes

What are u saying?
I am using a Local Script.

2 Likes

A Local Script is a client sided script. I’m telling you to use a Script (server sided) instead because Touched event only works in a server-sided script.

If you are already using a Script, then just say Script instead of Local Script.

2 Likes

Sorry, I didnt understood what you meant. Now, I understood it. But like i said. using a server-sided script gives me more issues.

1 Like

Can you give the errors that you encounter please ?

2 Likes