Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why won't this transfer information with the RemoteEvents?

Asked by 7 years ago

I'm trying to make a gun and

I want the Gui to update its stats(Ammo, Gun Name, Max Ammo).

ERROR:20:54:15.911 - Unable to cast value to Object

-- This a local script in the Pistol

local GunName = 'Pistol'
local Ammo = 20
local MaxAmmo = 20
Remote:FireClient(GunName,Ammo,MaxAmmo)
-- This a local script in the StarterGui

local Remote = game.ReplicatedStorage:WaitForChild('GunStatsRemote')
local Background = script.Parent:FindFirstChild('Background')
local AmmoLabel = Background.AmmoLabel
local GunLabel = Background.GunLabel
Remote.OnClientEvent:connect(function(GunName, Ammo, MaxAmmo)
GunLabel.Text = GunName
AmmoLabel.Text = Ammo..'/'..MaxAmmo
end)

I'm not sure how to fix this problem, I rarely use RemoteEvents.

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You can't use a remote event because your communicating between 2 local scripts. You can only use Remote events when communicating between a localScript and a normal Script or vice versa. Instead use a Bindable event http://wiki.roblox.com/index.php?title=API:Class/BindableEvent

0
Oooooooo UltraUnitMode 419 — 7y
1
ya, i ran into the same problem a couple weeks ago too. so i hope this helped :) HyperSpeed05 40 — 7y
Ad

Answer this question