I am new to making UI in Roblox studio and I am trying to make a ring from sonic. what is supposed to happen is that when you touch the ring it will fire a remote event that it will fire a remote event that will update the text label however when i touch the ring the " Argument 1 missing or nil" error message appears.
This is my script which is a child on the ring:
local ring = script.Parent local ringSparkle = ring.ParticleEmitter ringSparkle.Enabled = false local ReplicatedStorage = game:GetService("ReplicatedStorage") local ringUpdate = ReplicatedStorage:WaitForChild("ringCountUpdate") function destroy(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChild("Humanoid") if humanoid then ring.Transparency = 1 ring.CanCollide = false ringSparkle.Enabled = true wait(1) ring:Destroy() ringUpdate:FireClient() end end ring.Touched:Connect(destroy)
and this is my text label local script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local ringUpdate = ReplicatedStorage:WaitForChild("ringCountUpdate") local ringCount = script.Parent local ringCountInt = 0 ringCount.Text = tostring(ringCountInt) local function addRing () ringCountInt += 1 ringCount.Text = tostring(ringCountInt) end ringUpdate.OnClientEvent:Connect(addRing)
The FireClient function must always include a player as it’s first argument, otherwise it won’t send to the the client. To get the player from a character, you use Players:GetPlayerFromCharacter(CharacterModel)
.
local ring = script.Parent local ringSparkle = ring.ParticleEmitter ringSparkle.Enabled = false local ReplicatedStorage = game:GetService("ReplicatedStorage") local ringUpdate = ReplicatedStorage:WaitForChild("ringCountUpdate") function destroy(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChild("Humanoid") local playerFromCharacter = game:GetService("Players"):GetPlayerFromCharacter(partParent) if partParent and humanoid and playerFromCharacter then ring.Transparency = 1 ring.CanCollide = false ringSparkle.Enabled = true task.wait(1) ring:Destroy() ringUpdate:FireClient(playerFromCharacter) end end ring.Touched:Connect(destroy)