I'm trying to make a player shrink, speed up, and become invisible when they touch a certain part, using a client-to-server remote event.
Here's the local script:
local player = game.Players.LocalPlayer local char = player.Character or player.CharacterAdded:Wait() local hum = char:WaitForChild("Humanoid") local debounce = false local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEventTest") local function inkTouched(part) if not debounce then debounce = true if part.Name == "Ink" then RemoteEvent:FireServer(player, char, hum) print("Client communicating with server...") end end debounce = false end hum.Touched:Connect(inkTouched)
And here's the server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEventTest") local function inkTouched(player, char, hum) hum.HeadScale = 0.05 hum.BodyDepthScale = 0.05 hum.BodyWidthScale = 0.05 hum.BodyHeightScale = 0.05 hum.WalkSpeed = 32 for _, item in pairs(char:GetChildren()) do if item:IsA("BasePart") then item.Transparency = 1 end end print("Communication successful!") end RemoteEvent.OnServerEvent:Connect(inkTouched)
When I run the game, the remote event itself worked but I get this error: "HeadScale is not a valid member of Model 'Workspace.Isocyanic'". Why?
One thing, the scales
are based on RBXVALUEOBJECTS
, so.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEventTest") local function inkTouched(player, char, hum) hum.HeadScale.Value = 0.05 hum.BodyDepthScale.Value = 0.05 hum.BodyWidthScale.Value = 0.05 hum.BodyHeightScale.Value = 0.05 hum.WalkSpeed = 32 for _, item in pairs(char:GetChildren()) do if item:IsA("BasePart") then item.Transparency = 1 end end print("Communication successful!") end RemoteEvent.OnServerEvent:Connect(inkTouched)
A cleaner version is:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEventTest") local function inkTouched(player, char, hum) local function scale(n,r) if hum:FindFirstChild(n.."Scale") then hum:FindFirstChild(n.."Scale").Value = r else warn("Not found " .. n) end end scale("BodyDepth",0.05) scale("BodyWidth",0.05) scale("BodyHeight",0.05) scale("Head",0.05) hum.WalkSpeed = 32 for _, item in pairs(char:GetChildren()) do if item:IsA("BasePart") then item.Transparency = 1 end end print("Communication successful!") end RemoteEvent.OnServerEvent:Connect(inkTouched)