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

Using Remote events to transfer values but it's giving me an error why?

Asked by
DevingDev 346 Moderation Voter
6 years ago
Edited 6 years ago

I'm using remote events to transfer values but it's giving me an error why? I'm trying to get it to work with filtering enabled but it did not work properly why?

Error:

16:17:45.092 - Unable to cast value to Object
16:17:45.093 - Stack Begin
16:17:45.093 - Script 'ServerScriptService.Script', Line 25
16:17:45.093 - Stack End

Local script:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local char = player.Character

local ActiveWeapon = char:FindFirstChild("ActiveWeapon")
--repeat wait() until ActiveWeapon

local rep = game.ReplicatedStorage
local Remotes = rep["Remotes"]

function weld(parent,part0,part1,c0,c1)
    print("Welding")
    local weld = Instance.new("Weld")
    weld.Parent = parent
    weld.Part0 = part0
    weld.Part1 = part1
    weld.C0 = c0
    weld.C1 = c1
    return weld
end

Remotes["WeldItem"].OnClientEvent:connect(function(player, Type, Item)
    print("Equipped: "..Item)
    local axe = game.ReplicatedStorage[Type][Item]:Clone()
    axe.Parent = player["ActiveWeapon"]

    local Handleweld = weld(ActiveWeapon,char["RightLowerArm"],axe.Handle,CFrame.new(0, .35, -1.5, 10, 0, 0, 0, 1, 0, 0, 0, 1),CFrame.new(-1.00324273, 0.013961792, -0.00828075409, -1.38366803e-013, -0.999999881, 4.25688995e-009, 2.4656245e-007, -4.25688951e-009, -1, 1, -1.373172e-013, 2.4656245e-007))
    local Bladeweld = weld(ActiveWeapon,axe.Handle,axe["Axe Blade"],CFrame.new(0, 2.5, 0, 10, 0, 0, 0, 1, 0, 0, 0, 1),CFrame.fromEulerAnglesXYZ(-1.6, 0.013961792, -0.00828075409, -1.38366803e-013, -0.999999881, 4.25688995e-009, 2.4656245e-007, -4.25688951e-009, -1, 1, -1.373172e-013, 2.4656245e-007))
end)

Server script:

local a = "Axes"
local b = "Metal Axe"

Remotes["WeldItem"]:FireClient(a, b)

1 answer

Log in to vote
0
Answered by 6 years ago

This errors since you did not specify the client you want to send this data to. To do this, you would do

local a = "Axes"
local b = "Metal Axe"

Remotes["WeldItem"]:FireClient(game.Players.hiimgoodpack, a, b)

Also, the player parameter does not get passed through with OnClientEvent. ROBLOX thinks your smart enough to use game.Players.LocalPlayer.

Also, please try avoiding large or complicated numbers or I may explode before I get to answer your question D:

Hope this helps!

0
so i'm sepose to do this on the local side: Remotes["WeldItem"].OnClientEvent:connect(function(player, Type, Item)? DevingDev 346 — 6y
0
Cause i'm just getting this error otherwise 16:34:46.379 - FireClient: player argument must be a Player object DevingDev 346 — 6y
Ad

Answer this question